OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
<% active_section_keys = @custom_action.actions.map(&:key) %>
<div class="form--field -required">
<%= 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}]" %>
<div class="form--field-container">
<div class="form--select-container -middle">
<% if condition.key == :project %>
<%= angular_component_tag "opce-project-autocompleter",
inputs: {
multiple: true,
filters: [{ name: "active", operator: "=", values: ["t"] }],
resource: "projects",
inputName: input_name,
appendTo: "body",
labelForId: "custom_action_actions_#{condition.key}",
inputValue: condition.values
} %>
<% else %>
<%= angular_component_tag "opce-autocompleter",
inputs: {
multiple: true,
defaultData: false,
items: condition.allowed_values.map { |v| { id: v[:value], name: v[:label] } },
model: condition.value_objects.map { |v| { id: v[:value], name: v[:label] } },
inputName: input_name,
bindLabel: "name",
labelForId: "custom_action_conditions_#{condition.key}",
appendTo: "body"
} %>
<% end %>
</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| %>
<section class="hide-section"
data-hide-sections-target="section"
data-name="<%= action.key %>"
<%= tag.attributes(data: { section_name: action.key }, hidden: active_section_keys.include?(action.key) ? nil : true) %>
>
<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 user project).include?(action.type) %>
<div class="form--field-container">
<div class="form--select-container -middle">
<% case action %>
<% in { type: :project } %>
<%= angular_component_tag "opce-project-autocompleter",
inputs: {
multiple: false,
filters: [{ name: "active", operator: "=", values: ["t"] }],
resource: "projects",
inputName: input_name,
appendTo: "body",
labelForId: "custom_action_actions_#{action.key}",
inputValue: action.values.first
} %>
<% in { type: :user, custom_field_based: false } %>
<% selected = action.value_objects.map { |v| { id: v[:value], name: v[:label] } } %>
<%= angular_component_tag "opce-user-autocompleter",
inputs: {
multiple: action.multi_value?,
hideSelected: true,
defaultData: false,
placeholder: I18n.t(:label_user_search),
resource: "principals",
url: ::API::V3::Utilities::PathHelper::ApiV3Path.principals,
model: action.multi_value? ? selected : selected.first,
inputName: input_name,
filters: [
{ name: "status", operator: "!", values: [Principal.statuses["locked"].to_s] }
],
appendTo: "body",
additionalOptions: [
{ id: nil, name: I18n.t("placeholders.default") },
{ id: action.current_user_value_key, name: action.current_user_name }
],
searchKey: "any_name_attribute",
labelForId: "custom_action_actions_#{action.key}",
focusDirectly: false
} %>
<% else %>
<% selected = action.value_objects.map { |v| { id: v[:value], name: v[:label] } } %>
<%= angular_component_tag "opce-autocompleter",
inputs: {
multiple: action.multi_value?,
hideSelected: true,
defaultData: false,
items: action.allowed_values.map { |v| { id: v[:value], name: v[:label] } },
model: action.multi_value? ? selected : selected.first,
inputName: input_name,
bindLabel: "name",
labelForId: "custom_action_actions_#{action.key}",
appendTo: "body"
} %>
<% end %>
</div>
</div>
<% elsif %i(date_property).include?(action.type) %>
<div class="form--field-container">
<% date = action.values.first %>
<%= angular_component_tag "opce-custom-date-action-admin",
data: { "field-value": date.try(:iso8601) || date, "field-name": input_name } %>
</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 %i(link_property).include?(action.type) %>
<div class="form--field-container">
<%= styled_url_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 %>
<button type="button"
class="spot-link"
title="<%= t(:button_close) %>"
data-action="click->hide-sections#hide">
<%= op_icon("icon-close icon-small") %>
</button>
</div>
</section>
<% end %>
</div>
<div class="form--space"></div>
<div class="form--field">
<label class="form--label" for="add-custom-action-select">
<%= op_icon("icon-add icon4") %>
<%= I18n.t(:"custom_actions.actions.add") %>
</label>
<span class="form--field-container">
<span class="form--select-container -middle">
<%= select_tag "add_action",
options_for_select(
@custom_action.all_actions.map { |a| [a.human_name, a.key] },
disabled: active_section_keys
),
id: "add-custom-action-select",
prompt: t(:"custom_actions.actions.add"),
data: {
"hide-sections-target": "select",
action: "change->hide-sections#add"
},
class: "form--select" %>
</span>
</span>
</div>
</fieldset>