-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8251 from dmarcoux/bootstrap-attributes
Replace Bento by Bootstrap for attributes
- Loading branch information
Showing
19 changed files
with
199 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
= form_for(@attribute) do |attribute_form| | ||
- if @attribute.errors.any? | ||
- value_fields_locals = { attribute: attribute, allowed_values: allowed_values } | ||
- issue_fields_locals = { issue_trackers: issue_trackers } | ||
|
||
= form_for(attribute) do |form| | ||
= form.hidden_field(:attrib_type_id) | ||
|
||
- errors = attribute.errors | ||
- if errors.present? | ||
#error-explanation | ||
%h2 | ||
= pluralize(@attribute.errors.count, "error") | ||
prohibited this attribute from being saved: | ||
%h2 "#{pluralize(errors.count, 'error')} prohibited this attribute from being saved:" | ||
%ul | ||
- @attribute.errors.full_messages.each do |message| | ||
%li | ||
= message | ||
- errors.full_messages.each do |message| | ||
%li= message | ||
|
||
#values | ||
= attribute_form.fields_for :values do |value| | ||
= render 'value_fields', f: value | ||
- if @attribute.values_addable? | ||
= form.fields_for :values do |value| | ||
= render('value_fields', { f: value }.merge(value_fields_locals)) | ||
- if attribute.values_addable? | ||
%p | ||
= link_to_add_association('Add a value', attribute_form, :values) | ||
- if @attribute.attrib_type.issue_list | ||
= link_to_add_association(form, :values, render_options: { locals: value_fields_locals }, title: 'Add a value') do | ||
%i.fas.fa-plus-circle.text-success | ||
Add a value | ||
- if issue_trackers | ||
#issues | ||
= attribute_form.fields_for :issues do |issue| | ||
= render 'issue_fields', f: issue | ||
%p | ||
= link_to_add_association 'add issue', attribute_form, :issues | ||
.actions | ||
= attribute_form.hidden_field(:attrib_type_id) | ||
= form.fields_for :issues do |issue| | ||
= render('issue_fields', { f: issue }.merge(issue_fields_locals)) | ||
%p | ||
= attribute_form.submit('Save') | ||
= link_to_add_association(form, :issues, render_options: { locals: issue_fields_locals }, title: 'Add an issue') do | ||
%i.fas.fa-plus-circle.text-primary | ||
Add an issue | ||
|
||
= link_to('Back', index_attribs_path, class: 'btn btn-outline-secondary', role: 'button') | ||
= form.submit('Save', class: 'btn btn-primary') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
.nested-fields | ||
.field | ||
= f.select :issue_tracker_id, IssueTracker.all.collect { |tracker| [tracker.name, tracker.id] }.sort, include_blank: false | ||
= f.label :id | ||
= f.text_field :name | ||
= link_to_remove_association "remove issue", f | ||
.field.form-row.form-group | ||
.col-auto | ||
= f.collection_select(:issue_tracker_id, issue_trackers, :id, :name, {}, class: 'form-control') | ||
.col-auto.col-form-label | ||
= f.label(:id, 'ID:') | ||
.col | ||
= f.text_field(:name, class: 'form-control') | ||
.col-auto.col-form-label | ||
= link_to_remove_association(f, title: 'Delete issue') do | ||
%i.fas.fa-times-circle.text-danger |
30 changes: 18 additions & 12 deletions
30
src/api/app/views/webui/attribute/_value_fields.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
.nested-fields | ||
.field | ||
%p | ||
- if @attribute.values_addable? | ||
= f.label :position | ||
= f.number_field :position, class: "attrib-position-input", size: 3 | ||
= f.label :value | ||
- if @attribute.attrib_type.allowed_values.any? | ||
= f.select :value, @attribute.attrib_type.allowed_values.map(&:value), { include_blank: false }, { id: 'attrib-default-select' } | ||
- else | ||
= f.text_area :value | ||
- if @attribute.values_removeable? | ||
= link_to_remove_association('Remove value', f) | ||
.field.form-row.form-group | ||
- if attribute.values_addable? | ||
.col-auto.col-form-label | ||
= f.label(:position, 'Position:') | ||
.col-1 | ||
= f.number_field(:position, class: 'form-control', min: 1) | ||
.col-auto.col-form-label | ||
= f.label(:value, 'Value:') | ||
- if allowed_values.present? | ||
.col-auto | ||
= f.select(:value, allowed_values, {}, class: 'form-control') | ||
- else | ||
.col | ||
= f.text_area(:value, class: 'form-control') | ||
- if attribute.values_removeable? | ||
.col-auto.col-form-label | ||
= link_to_remove_association(f, title: 'Delete value') do | ||
%i.fas.fa-times-circle.text-danger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
- @pagetitle = "Edit Attribute #{@attribute.fullname} on #{@container.class} #{@container.name}" | ||
- project_bread_crumb | ||
- if @package | ||
- @crumb_list << link_to(@package, package_show_path(package: @package)) | ||
- @crumb_list << link_to('Attributes', index_attribs_path(project: @project.name, package: @package)) | ||
- else | ||
- @crumb_list << link_to('Attributes', index_attribs_path(project: @project.name)) | ||
- @crumb_list << @attribute.fullname | ||
- if @package | ||
= render partial: "webui/package/tabs" | ||
- else | ||
= render partial: "webui/project/tabs" | ||
%h2 | ||
= @pagetitle | ||
%p | ||
= @attribute.attrib_type.description | ||
- if @attribute.values_editable? | ||
= render 'form' | ||
- else | ||
%p | ||
This attribute has no values to edit | ||
.card | ||
= render(partial: "webui/#{@container.model_name.singular}/tabs", locals: { project: @project, package: @package }) | ||
|
||
.card-body | ||
%h3= @pagetitle | ||
%p | ||
= @attribute.attrib_type.description | ||
- if @attribute.values_editable? | ||
= render(partial: 'form', locals: { attribute: @attribute, issue_trackers: @issue_trackers, allowed_values: @allowed_values }) | ||
- else | ||
%p | ||
This attribute has no values to edit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,46 @@ | ||
- @pagetitle = "Attributes" | ||
- project_bread_crumb | ||
- if @package | ||
- @crumb_list << link_to(@package, package_show_path(package: @package)) | ||
- @crumb_list << "Attributes" | ||
- if @package | ||
= render partial: "webui/package/tabs" | ||
- else | ||
= render partial: "webui/project/tabs" | ||
= render partial: "attributes" | ||
- @pagetitle = "Attributes of #{@package ? "#{@package} (Project #{@project})" : "Project #{@project}"}" | ||
- can_update_container = policy(@container).update? | ||
|
||
.card | ||
= render(partial: "webui/#{@container.model_name.singular}/tabs", locals: { project: @project, package: @package }) | ||
|
||
.card-body | ||
%h3= @pagetitle | ||
- if @attributes.present? | ||
%table.responsive.table.table-bordered.table-hover.w-100#attributes | ||
%thead | ||
%tr | ||
%th Attributes | ||
%th Values | ||
- if can_update_container | ||
%th Actions | ||
%tbody | ||
- @attributes.each do |attribute| | ||
%tr | ||
%td.text-word-break-all= attribute.fullname | ||
%td | ||
%ul | ||
- unless attribute.values.empty? | ||
- attribute.values.each do |v| | ||
%li.value | ||
%pre.d-inline= v.value | ||
- unless attribute.issues.empty? | ||
%li= attribute.issues.map(&:name).to_sentence | ||
- if can_update_container | ||
%td | ||
- if attribute.values_editable? | ||
= link_to(edit_attribs_path(project: @project.name, package: @package, attribute: attribute.fullname), title: 'Edit values') do | ||
%i.fas.fa-edit.text-secondary | ||
= link_to('#', title: 'Delete attribute', | ||
data: { toggle: 'modal', target: '#delete-attribute-modal', action: attrib_path(attribute), fullname: attribute.fullname }) do | ||
%i.fas.fa-times-circle.text-danger | ||
- else | ||
%p | ||
%em No attributes set | ||
|
||
- if can_update_container | ||
%p | ||
= link_to(new_attribs_path(project: @project.name, package: @package), title: 'Add a new attribute') do | ||
%i.fas.fa-plus-circle.text-primary | ||
Add a new attribute | ||
= render(partial: 'delete_dialog') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
- @pagetitle = "Add Attribute" | ||
- project_bread_crumb | ||
- if @package | ||
- @crumb_list << link_to(@package, package_show_path(package: @package)) | ||
- @crumb_list << link_to('Attributes', index_attribs_path(project: @project.name, package: @package)) | ||
- else | ||
- @crumb_list << link_to('Attributes', index_attribs_path(project: @project.name)) | ||
- @crumb_list << "Add" | ||
- if @package | ||
= render partial: "webui/package/tabs" | ||
- else | ||
= render partial: "webui/project/tabs" | ||
%h2 | ||
= @pagetitle | ||
= form_for(@attribute) do |f| | ||
.field | ||
%p | ||
= f.select :attrib_type_id, AttribType.includes(:attrib_namespace).collect { |a| [a.fullname, a.id] }.sort, include_blank: false | ||
= hidden_field_tag("attrib[project_id]", @attribute.project_id) | ||
= hidden_field_tag("attrib[package_id]", @attribute.package_id) if @attribute.package_id | ||
%p.help-block#first-help | ||
= AttribType.all.to_a.sort_by { |t| t.fullname }.first.description | ||
= "Sorry, this attribute has no description" if AttribType.all.to_a.sort_by { |t| t.fullname }.first.description.blank? | ||
- AttribType.all.each do |type| | ||
%p.help-block.attrib-type{ id: "#{type.id}-help" } | ||
= type.description | ||
= "Sorry, this attribute has no description" if type.description.blank? | ||
.actions | ||
%p | ||
= f.submit('Add') | ||
- @pagetitle = 'Add Attribute' | ||
|
||
.card | ||
= render(partial: "webui/#{@container.model_name.singular}/tabs", locals: { project: @project, package: @package }) | ||
|
||
.card-body | ||
%h3= @pagetitle | ||
= form_for(@attribute) do |form| | ||
.form-row | ||
= form.hidden_field(:project_id) | ||
- if @attribute.package_id | ||
= form.hidden_field(:package_id) | ||
.col-12.col-md-auto | ||
= form.collection_select(:attrib_type_id, @attribute_types, :id, :fullname, {}, class: 'form-control custom-select') | ||
.col-form-label.col-12.col-md | ||
- @attribute_types.each do |attribute_type| | ||
%p.d-none{ id: "attribute_type-description-#{attribute_type.id}" } | ||
= attribute_type.description.presence || 'Sorry, this attribute has no description' | ||
= link_to('Back', index_attribs_path, class: 'btn btn-outline-secondary', role: 'button') | ||
= form.submit('Add', class: 'btn btn-primary') |
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/api/app/views/webui2/webui/attribute/_issue_fields.html.haml
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
src/api/app/views/webui2/webui/attribute/_value_fields.html.haml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.