wip: form_configuration

pull/5212/head
Wieland Lindenthal 8 years ago committed by Oliver Günther
parent db5cee6559
commit 14e48a7e16
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 50
      app/assets/stylesheets/content/_types_form_configuration.sass
  2. 164
      app/views/types/form/_form_configuration.html.erb

@ -1,23 +1,37 @@
#types-form-configuration
.attribute-group
.attribute-group,
.inactive-group
border-radius: 2px
padding: 0px 4px 2px 4px
margin-bottom: 20px
.group-head
color: $font-color-on-primary-dark
padding: 4px 4px 4px 4px
text-transform: uppercase
.group-handle
cursor: move
.attribute-visibility
float: right
.attributes
.attribute
padding: 3px 4px 3px 4px
margin-bottom: 2px
background: $gray-light
border-top-left-radius: 2px
border-bottom-left-radius: 2px
border-top-right-radius: 2px
border-bottom-right-radius: 2px
.attribute-handle
cursor: move
.attribute-visibility
float: right
.attribute-group
background: $primary-color
.inactive-group
background: $gray-dark
cursor: move
table
border-collapse: separate
border-spacing: 0 2px
thead
color: $font-color-on-primary-dark
tbody
tr
background: $gray-light
td:first-child
padding-left: 10px
border-top-left-radius: 2px
border-bottom-left-radius: 2px
td:last-child
padding-right: 10px
border-top-right-radius: 2px
border-bottom-right-radius: 2px
.attributes
min-height: 40px

@ -34,121 +34,55 @@ See doc/COPYRIGHT.rdoc for more details.
<p><%= I18n.t('text_form_configuration') %></p>
<types-form-configuration id="types-form-configuration" dragula="'groups'">
<div class="attribute-group">
<table class="attributes-table -two-options">
<thead>
<tr>
<th><span class="group-handle">::</span></th>
<th> 1 <%= I18n.t('label_attribute') %></th>
<th class="attributes-table--option"><%= I18n.t('label_active') %></th>
<th class="attributes-table--option"><%= I18n.t('label_always_visible') %></th>
</tr>
</thead>
<tbody dragula="'attributes'">
<%
attributes = ::TypesHelper
.work_package_form_attributes(merge_date: true)
.reject { |name, attr|
# display all custom fields don't display required fields without a default
not name =~ /custom_field_/ and (attr[:required] and not attr[:has_default])
}
keys = attributes.keys.sort_by do |name|
translated_attribute_name(name, attributes[name])
end
%>
<% keys.each do |name| %>
<% attr = attributes[name] %>
<tr>
<td><span class="attribute-handle">::</span></td>
<td>
<%= label_tag "type_attribute_visibility_#{name}",
translated_attribute_name(name, attr),
value: "type_attribute_visibility[#{name}]",
class: 'ellipsis' %>
</td>
<td>
<input name="<%= "type[attribute_visibility][#{name}]" %>" type="hidden" value="hidden" />
<% active_checked = [nil, 'default', 'visible'].include?(attr_visibility(name, @type)) %>
<%= check_box_tag "type[attribute_visibility][#{name}]",
'default',
active_checked,
id: "type_attribute_visibility_default_#{name}",
title: I18n.t('tooltip.attribute_visibility.default') %>
</td>
<td>
<%= check_box_tag "type[attribute_visibility][#{name}]",
'visible',
attr_visibility(name, @type) == 'visible',
id: "type_attribute_visibility_visible_#{name}",
title: I18n.t('tooltip.attribute_visibility.visible'),
disabled: !active_checked %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div> <!-- END attribute group -->
<div class="attribute-group">
<table class="attributes-table -two-options">
<thead>
<tr>
<th><span class="group-handle">::</span></th>
<th><span class="group-handle">::</span> 2 <%= I18n.t('label_attribute') %></th>
<th class="attributes-table--option"><%= I18n.t('label_active') %></th>
<th class="attributes-table--option"><%= I18n.t('label_always_visible') %></th>
</tr>
</thead>
<tbody dragula="'attributes'">
<%
attributes = ::TypesHelper
.work_package_form_attributes(merge_date: true)
.reject { |name, attr|
# display all custom fields don't display required fields without a default
not name =~ /custom_field_/ and (attr[:required] and not attr[:has_default])
}
keys = attributes.keys.sort_by do |name|
translated_attribute_name(name, attributes[name])
end
%>
<% keys.each do |name| %>
<% attr = attributes[name] %>
<tr>
<td><span class="attribute-handle">::</span></td>
<td>
<%= label_tag "type_attribute_visibility_#{name}",
translated_attribute_name(name, attr),
value: "type_attribute_visibility[#{name}]",
class: 'ellipsis' %>
</td>
<td>
<input name="<%= "type[attribute_visibility][#{name}]" %>" type="hidden" value="hidden" />
<% active_checked = [nil, 'default', 'visible'].include?(attr_visibility(name, @type)) %>
<%= check_box_tag "type[attribute_visibility][#{name}]",
'default',
active_checked,
id: "type_attribute_visibility_default_#{name}",
title: I18n.t('tooltip.attribute_visibility.default') %>
</td>
<td>
<%= check_box_tag "type[attribute_visibility][#{name}]",
'visible',
attr_visibility(name, @type) == 'visible',
id: "type_attribute_visibility_visible_#{name}",
title: I18n.t('tooltip.attribute_visibility.visible'),
disabled: !active_checked %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div> <!-- END attribute group -->
<% @type.attribute_groups.each do |group_name, group_attributes| %>
<div class="attribute-group">
<div class="group-head">
<span class="group-handle">::</span>
<span class="group-name"><%= group_name %></span>
<div class="attribute-visibility"><%= I18n.t('label_always_visible') %></div>
</div>
<div class="attributes" dragula="'attributes'">
<%
attributes = ::TypesHelper
.work_package_form_attributes(merge_date: true)
.reject { |name, attr|
# display all custom fields don't display required fields without a default
not name =~ /custom_field_/ and (attr[:required] and not attr[:has_default])
}
# keys = attributes.keys.sort_by do |name|
# translated_attribute_name(name, attributes[name])
# end
%>
<% group_attributes.each do |name| %>
<% attr = attributes[name] %>
<div class="attribute">
<span class="attribute-handle">::</span>
<span class="attribute-name">
<%= name %>
</span>
<div class="attribute-visibility">
<%= check_box_tag "type[attribute_visibility][#{name}]",
'visible',
attr_visibility(name, @type) == 'visible',
id: "type_attribute_visibility_visible_#{name}",
title: I18n.t('tooltip.attribute_visibility.visible') %>
</div>
</div>
<% end %>
</div>
</div> <!-- END attribute group -->
<% end %>
<div class="inactive-group">
<div class="group-head">
<span class="group-handle">::</span>
<span class="group-name">Inactive attributes</span>
</div>
<div class="attributes" dragula="'attributes'">
</div>
</div>
</types-form-configuration> <!-- END type form configurator -->
</div>

Loading…
Cancel
Save