wip: angularjs-dragula for form_configuration

pull/5212/head
Wieland Lindenthal 8 years ago committed by Oliver Günther
parent 9bffe6225f
commit b58721a70a
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 1
      app/assets/stylesheets/content/_index.sass
  2. 23
      app/assets/stylesheets/content/_types_form_configuration.sass
  3. 169
      app/views/types/form/_form_configuration.html.erb
  4. 50
      frontend/app/components/types/form-configuration/types-form-configuraiton.directive.ts

@ -41,6 +41,7 @@
@import content/tables
@import content/tabular
@import content/timelines
@import content/types_form_configuration
@import content/user
@import content/preview
@import content/modal

@ -0,0 +1,23 @@
#types-form-configuration
.attribute-group
border-radius: 2px
padding: 0px 4px 2px 4px
margin-bottom: 20px
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

@ -32,56 +32,125 @@ See doc/COPYRIGHT.rdoc for more details.
<div class="grid-content small-12 large-6">
<div>
<p><%= I18n.t('text_form_configuration') %></p>
<table class="attributes-table -two-options">
<thead>
<tr>
<th><%= 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>
<%
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>
<%= 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>
<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 -->
</types-form-configuration> <!-- END type form configurator -->
</div>
</div>
</div>

@ -0,0 +1,50 @@
//-- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
import {openprojectModule} from '../../../angular-modules';
function typesFormConfiguration(I18n:op.I18n) {
return {
restrict: 'E',
controller: function($scope:any, dragulaService:any) {
dragulaService.options($scope, 'groups', {
moves: function (el:any, container:any, handle:any) {
return handle.className === 'group-handle';
}
});
dragulaService.options($scope, 'attributes', {
moves: function (el:any, container:any, handle:any) {
return handle.className === 'attribute-handle';
}
});
}
};
};
openprojectModule.directive('typesFormConfiguration', typesFormConfiguration);
Loading…
Cancel
Save