OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/views/custom_actions/_form.html.erb

121 lines
5.2 KiB

<%= activate_angular_js do %>
<%= initialize_hide_sections_with @custom_action.all_actions.map { |a| { key: a.key, label: a.human_name } },
@custom_action.actions.map { |a| { key: a.key, label: a.human_name } } %>
<div class="form--field">
<%= f.text_field :name, required: true, container_class: '-middle' %>
</div>
<div class="form--field">
<%= f.text_area :description, container_class: '-middle' %>
</div>
<fieldset class="form--fieldset" id="custom-actions-form--conditions">
<legend class="form--fieldset-legend">
<%= t('custom_actions.conditions') %>
</legend>
<% @custom_action.all_conditions.each do |condition| %>
<div class="form--field">
<%= styled_label_tag("custom_action_conditions_#{condition.key}", condition.human_name, class: '-top') %>
<% input_name = "custom_action[conditions][#{condition.key}]" %>
<% selected_values = condition.values
select_options = options_for_select(condition.allowed_values.map { |v| [v[:label], v[:value]] },
selected: selected_values) %>
<div class="form--field-container">
<div class="form--select-container -middle">
<autocomplete-select-decoration>
<%= select_tag input_name,
select_options,
multiple: true %>
</autocomplete-select-decoration>
</div>
</div>
</div>
<div class="form--space"></div>
<% end %>
</fieldset>
<fieldset class="form--fieldset" id="custom-actions-form--actions">
<legend class="form--fieldset-legend">
<%= t('custom_actions.actions.name') %>
</legend>
<div id="custom-actions-form--active-actions">
<% @custom_action.all_actions.each do |action| %>
<hide-section section-name="<%= action.key %>">
<div class="form--field">
<%= styled_label_tag("custom_action_actions_#{action.key}", action.human_name, class: '-top') %>
<% input_name = "custom_action[actions][#{action.key}]" %>
<% if %i(associated_property boolean).include?(action.type) %>
<% selected_values = action.values
select_options = options_for_select(action.allowed_values.map { |v| [v[:label], v[:value]] },
selected: selected_values) %>
<div class="form--field-container">
<div class="form--select-container -middle">
<autocomplete-select-decoration
label="<%=action.human_name%>">
<%= select_tag input_name,
select_options,
multiple: action.multi_value? %>
</autocomplete-select-decoration>
</div>
</div>
<% elsif %i(date_property).include?(action.type) %>
<div class="form--field-container">
<wp-custom-actions-admin-date-action field-value="<%= action.values.first %>"
field-name="<%= input_name %>">
</wp-custom-actions-admin-date-action>
</div>
<% elsif %i(string_property text_property).include?(action.type) %>
<div class="form--field-container">
<%= styled_text_field_tag input_name,
action.values,
container_class: '-slim',
step: 'any' %>
</div>
<% elsif action.type == :float_property %>
<div class="form--field-container">
<%= styled_number_field_tag input_name,
action.values,
container_class: '-slim',
min: action.minimum,
max: action.maximum,
step: 'any' %>
</div>
<% elsif action.type == :integer_property %>
<div class="form--field-container">
<%= styled_number_field_tag input_name,
action.values,
container_class: '-slim',
min: action.minimum,
max: action.maximum,
step: 1 %>
</div>
<% end %>
<hide-section-link section-name="'<%= action.key %>'"></hide-section-link>
</div>
</hide-section>
<% end %>
</div>
<div class="form--space"></div>
<div class="form--field">
<label class="form--label" for="custom-actions-form--add-action">
<%= op_icon("icon-add icon4") %>
<%= I18n.t(:'custom_actions.actions.add') %>
</label>
<span class="form--field-container">
<span class="form--text-field-container -middle">
<add-section-dropdown html-id="'custom-actions-form--add-action'"
id="custom-actions-form--selectable-actions">
</add-section-dropdown>
</span>
</span>
</div>
</fieldset>
<% end %>