forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_edit_field.html.haml
160 lines (151 loc) · 7.52 KB
/
_edit_field.html.haml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
- url = url_for_only_path(:action => 'exp_changed')
-# Parameters:
-# exp_model Model in use for this expression
%br
- opts = ["<#{_('Choose')}>"]
- if exp_model == "_display_filter_"
-# Use list in @edit for reporting display filter
- opts += @edit[@expkey][:exp_available_fields]
- else
- opts += MiqExpression.miq_adv_search_lists(exp_model, :exp_available_fields)
= select_tag('chosen_field', options_for_select(opts, @edit[@expkey][:exp_field]),
:multiple => false,
:class => 'selectpicker',
'data-live-search' => true,
'data-miq_sparkle_on' => true,
'data-miq_sparkle_off' => true)
- if adv_search_show_alias_checkbox? && !@edit[@expkey][:exp_field].blank?
%br
= check_box_tag("use_alias", "1", !@edit[@expkey][:alias].blank?,
:style => "width: 20px",
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true,
"data-miq_observe_checkbox" => {:url => url}.to_json)
= _('Use Alias')
- unless @edit[@expkey][:alias].blank?
= text_field_tag("alias", @edit[@expkey][:alias],
:maxlength => 50,
"data-miq_observe" => {:interval => '.5', :url => url}.to_json)
- if @edit[@expkey][:exp_field]
%br
- if @edit[@expkey][:exp_key] == "CONTAINS"
%font{:color => "black"}
= h(@edit[@expkey][:exp_key])
- else
= select_tag('chosen_key',
options_for_select(MiqExpression.get_col_operators(@edit[@expkey][:exp_field]), @edit[@expkey][:exp_key]),
:multiple => false,
:class => 'selectpicker',
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)
- unless @edit[@expkey][:exp_key].include?("NULL") || @edit[@expkey][:exp_key].include?("EMPTY")
%br
%span#chosen_value_span
- if @edit[@expkey][:val1][:type] == :boolean
- if @edit[@expkey][:exp_value] == :user_input
= "<user input>"
- else
- values = [[_("true"), "true"], [_("false"), "false"]]
- if @edit[@expkey][:exp_value].blank?
- values.insert(0, ["<#{_('Choose')}>", ""])
= select_tag('chosen_value',
options_for_select(values, @edit[@expkey][:exp_value]),
:multiple => false,
:class => 'selectpicker',
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)
- elsif [:date, :datetime].include?(@edit[@expkey][:val1][:type])
- if @edit[@expkey][:val1][:date_format] == 's'
= datepicker_input_tag("miq_date_1_0",
@edit[@expkey][:exp_value][0] ? @edit[@expkey][:exp_value][0].split(" ").first : "",
:readonly => "true",
:size => 10,
"data-miq_observe_date" => {:interval => '.5', :url => url}.to_json)
- if @edit[@expkey][:exp_value][0].to_s.include?(":")
= select_tag("miq_time_1_0",
options_for_select(Array.new(24) { |i| ["#{i}:00", "#{i}:15", "#{i}:30", "#{i}:45"] }.flatten, @edit[@expkey][:exp_value][0].split(" ").last),
:class => 'selectpicker',
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)
- else
- opts = (@edit[@expkey][:val1][:type] == :datetime ? ViewHelper::FROM_HOURS : [])
- opts += ViewHelper::FROM_DAYS + ViewHelper::FROM_WEEKS + ViewHelper::FROM_MONTHS + ViewHelper::FROM_QUARTERS + ViewHelper::FROM_YEARS
= select_tag('chosen_from_1',
options_for_select(Hash[opts.map {|x| [_(x), x]}], @edit[@expkey][:exp_value][0]),
:class => 'selectpicker',
:multiple => false,
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)
- if @edit[@expkey][:exp_key] == ApplicationController::Filter::EXP_FROM && @edit[@expkey][:exp_value][0]
%br
= _('THROUGH')
%br
- if @edit[@expkey][:val1][:date_format] == 's'
= datepicker_input_tag("miq_date_1_1",
@edit[@expkey][:exp_value][1] ? @edit[@expkey][:exp_value][1].split(" ").first : "",
:readonly => "true",
:size => 10,
"data-miq_observe_date" => {:interval => '.5', :url => url}.to_json)
- if @edit[@expkey][:exp_value][1].to_s.include?(":")
= select_tag("miq_time_1_1",
options_for_select(Array.new(24) { |i| ["#{i}:00", "#{i}:15", "#{i}:30", "#{i}:45"] }.flatten, @edit[@expkey][:exp_value][1].split(" ").last),
:class => 'selectpicker',
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)
- else
- if @edit[@expkey][:val1][:through_choices].length > 1
= select_tag('chosen_through_1',
options_for_select(@edit[@expkey][:val1][:through_choices], @edit[@expkey][:exp_value][1]),
:multiple => false,
:class => 'selectpicker',
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)
- else
= h(@edit[@expkey][:exp_value][1])
- if @edit[@expkey][:val1][:date_format] == 's'
- t = _('Click to change to a relative Date/Time format')
= link_to(image_tag(image_path('toolbars/specific_date.png'), :class => "rollover tiny", :alt => t),
{:action => 'exp_changed', :date_format_1 => 'r'},
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true,
:remote => true,
"data-method" => :post,
:title => t)
- else
- t = _('Click to change to a specific Date/Time format')
= link_to(image_tag(image_path('toolbars/relative_date.png'), :class => "rollover tiny", :alt => t),
{:action => 'exp_changed', :date_format_1 => 's'},
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true,
:remote => true,
"data-method" => :post,
:title => t)
- else
-# String field
- if @edit[@expkey][:exp_value] == :user_input
= "<#{_('user input')}>"
- else
= text_field_tag("chosen_value", @edit[@expkey][:exp_value],
:maxlength => 500,
"data-miq_observe" => {:interval => '.5', :url => url}.to_json)
- if @edit[@expkey][:val1][:type] == :percent
\%
- elsif @edit[@expkey][:val1][:type] == :megabytes
MB
- elsif MiqExpression::FORMAT_SUB_TYPES[@edit[@expkey][:val1][:type]][:units]
= select_tag('chosen_suffix',
options_for_select(MiqExpression::FORMAT_SUB_TYPES[@edit[@expkey][:val1][:type]][:units], @edit[@expkey].val1_suffix),
:multiple => false,
:class => 'selectpicker',
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)
:javascript
miqInitSelectPicker();
miqSelectPickerEvent('chosen_field', '#{url}');
miqSelectPickerEvent('chosen_key', '#{url}');
miqSelectPickerEvent('chosen_value', '#{url}');
miqSelectPickerEvent('chosen_suffix', '#{url}');
miqSelectPickerEvent('chosen_from_1', '#{url}');
miqSelectPickerEvent('miq_time_1_0', '#{url}');
miqSelectPickerEvent('miq_time_1_1', '#{url}');
miqSelectPickerEvent('chosen_through_1', '#{url}');