Show different color emoticons based on order status

Source: Internet
Author: User
Tags i18n
One: in Help according to the status of the corresponding CSS

Module Admin::order::D etailshelper  # Displays color problem status  Ps_bg_color = {"Finish" = "green", "Un_catch" and "Yellow", "Under_take" = "Red"}  def color_problem_status (detail)    %q{<span class= "UI circular label #{ps_bg_color [Detail.problem_status]} Basic "> #{detail.i18n_attr_problem_status} </span>}   endend

Second: Define a more flexible display by block.

<%= show_created_by_name (@company. created_by) do |name|%>          <div class= "column Column_new" > Creator: <%= name%> </div>  <% end%>    def show_created_by_name (created_by, &block)      name = Createdby.display_name (created_by)      if Block_given?        Capture (Name,&block) if name.present?      else        name      end  End

Three: Define state CSS by and i8n

Module Website Module EXT Module ActiveRecord module i18n extend Activesupport::concern i18n_attr_p          Refix =/^i18n_attr_/Name_of_prefix =/^name_of_/def method_missing (method,opt={}, *args, &block) c = method.to_s col = c.sub (I18n_attr_prefix, ") if C =~ i18n_attr_prefix col = c.sub (I 18n_attr_prefix, ') display_model_status (Self.class, col, Self.send (col.to_sym), opt) if self.class.column_names . Include? (col) elsif c =~ Name_of_prefix col = c.sub (Name_of_prefix, ') eval ("#{self.class.name}::#            {Col.upcase}.invert[self.#{col}] ") If eval (" #{self.class.name}.constants.include? (: #{col.upcase}) ") Else Super End End Def display_model_status (model,attribute,value,opt={}) return if Value.ni          L? If [' Active '].include? (Attribute.to_s.strip) s =:: i18n.t ("Activerecord.status.#{attribute}.#{value}", Default:vaLue) Else S =:: i18n.t ("Activerecord.status.#{model.name.underscore}.#{attribute}.#{value}", Default: Value) End If OPT[:CSS] s =%q{<span class= "UI circular label #{model.name.unde Rscore} #{attribute} #{value} basic "> #{s} </span>} End S end end, EndEnd tune By: <%=raw detail.i18n_attr_problem_status (css:true)%><%=raw detail.i18n_attr_problem_status%>enum Problem_status: {"normal" = 0, "Finish" =>1, "un_catch" = "Under_take" =>11}i8n:problem_ Status: ' normal ': ' ' Finish ': ' Problem order handled ' ' Un_catch ': ' Problem order not processed ' ' under_take ': ' Problem order Processing '    In ' css:/* issue order status color */.order_detail.problem_status.finish{color: #21BA45!important;     Background-color: #fff!important; border:1px solid #21BA45!important;    }.order_detail.problem_status.un_catch{color: #FBBD08!important;     Background-color: #fff!important; Border:1px solid #FBBD08!important;    }.order_detail.problem_status.under_take{color: #DB2828!important;     Background-color: #fff!important; border:1px solid #DB2828!important; }
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.