diff --git a/lib/Tuba/Generic.pm b/lib/Tuba/Generic.pm index 5b7f11b0..c8066f02 100644 --- a/lib/Tuba/Generic.pm +++ b/lib/Tuba/Generic.pm @@ -40,7 +40,7 @@ sub update { $c->redirect_without_error('update_form'); } # find any new attr keys or attribute_* keys - elsif ( exists $params->{new_attr_key} || grep { /^attribute/ } keys %$params ) { + elsif ( my $new_attributes = _collect_attributes($params) ) { my $new_attributes = _collect_attributes($params); $generic->set_attr( { new_attrs => $new_attributes, audit_user => $c->user, audit_note => "Setting attributes" }); $c->redirect_without_error('update_form'); @@ -59,7 +59,7 @@ sub _collect_attributes { my $new_attr_flag = 0; foreach my $key ( keys %$params ) { next if $key eq 'new_attr_value'; - if ( $key eq 'new_attr_key') { + if ( $key eq 'new_attr_key' && $params->{'new_attr_key'} ne '') { $new_attr_flag = 1; } if ( $key =~ /^attribute_(.*)/ && $params->{ $key } ) { diff --git a/lib/Tuba/files/templates/generic/update_form.html.ep b/lib/Tuba/files/templates/generic/update_form.html.ep index 9e4b100c..c19adad1 100644 --- a/lib/Tuba/files/templates/generic/update_form.html.ep +++ b/lib/Tuba/files/templates/generic/update_form.html.ep @@ -33,7 +33,7 @@ %= form_for obj_uri_for($object, 'update') => class => 'form-horizontal' => method => 'POST' => begin
- +
@@ -43,39 +43,64 @@ % for my $k (sort keys %{ $object->attrs }) { - - - - + + + + % } -
Attributes
Delete
<%= $k %><%= $object->attrs->{$k} %><%= text_field 'attribute_'.$k, class => "form-control input-small squeezevert" %><%= $k %><%= $object->attrs->{$k} %><%= text_field 'attribute_'.$k, class => "form-control input-small squeezevert" %>
-

New Attribute

-
-
- %= label_for 'new_attr_key', class => 'required' => begin - Key - %= end -
-
- <%= text_field 'new_attr_key', class => "form-control input-small squeezevert" %> -
-
- %= label_for 'new_attr_value', class => 'required' => begin - Value - %= end -
-
- <%= text_field 'new_attr_value', class => "form-control input-small squeezevert" %> -
-
+ +

New Attribute

+
+
+ %= label_for 'new_attr_key', class => 'required' => begin + Key + %= end +
+
+ <%= text_field 'new_attr_key', class => "form-control input-small squeezevert" %> +
+
+ %= label_for 'new_attr_value', class => 'required' => begin + Value + %= end +
+
+ <%= text_field 'new_attr_value', class => "form-control input-small squeezevert" %> +
+
-
-
- +
+
+
+ + +
+ + + % if ($self->can_set_replacement) { + If you would like this <%= $object->meta->table %> object's data merged into another <%= $object->meta->table %> upon deletion, select it here:
+ %= text_field 'replacement_identifier', autocomplete => 'off', id => 'replacement', placeholder => 'replacement', class => 'form-control col-lg-3 col-md-3', style=>'height:auto;'; + %= javascript begin + $('#replacement').typeahead({ + minLength : 2, + items : 15, + source : function(query,process) { + return $.get('/autocomplete', { q : query, items : 15, type : '<%= $object->meta->table %>' }, function(data) { + return process(data); + }); + } + }); + %= end + % } + +
+
+
-
+ + %= end