Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Bootstrap version of packages#attributes
- Loading branch information
Showing
13 changed files
with
210 additions
and
4 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 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$(document).ready(function() { | ||
// TODO: Edge case - When a user is already on the page and does a refresh, the description flickers as it appears. Find a way to fix this... | ||
$('#attribute_type-description-' + $('#attrib_attrib_type_id option:selected').val()).removeClass('d-none'); | ||
|
||
$('#attrib_attrib_type_id').change(function() { | ||
$("[id^='attribute_type-description-']:visible").addClass('d-none'); | ||
$('#attribute_type-description-' + $(this).val()).removeClass('d-none'); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
src/api/app/assets/stylesheets/webui2/package-attributes.scss
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ul li.value { | ||
&:not(:last-child) { | ||
margin-bottom: 5px; | ||
} | ||
|
||
& pre { | ||
background-color: #f6f6f6; | ||
border: 1px dotted #690; | ||
padding: 2px 3px; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -30,3 +30,4 @@ | |
@import 'texts'; | ||
@import 'build-results'; | ||
@import 'autocomplete'; | ||
@import 'package-attributes'; |
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 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Webui2::AttributeController | ||
def webui2_new | ||
@attribute_types = AttribType.includes(:attrib_namespace).all.sort_by(&:fullname) | ||
end | ||
|
||
def webui2_edit | ||
if @attribute.attrib_type.issue_list | ||
@issue_trackers = IssueTracker.order(:name).all | ||
end | ||
|
||
@allowed_values = @attribute.attrib_type.allowed_values.map(&:value) | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
src/api/app/views/webui2/webui/attribute/_breadcrumb_items.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
= render partial: 'webui/package/breadcrumb_items' | ||
|
||
- if current_page?(index_attribs_path) | ||
%li.breadcrumb-item.active{ 'aria-current' => 'page' } | ||
Attributes | ||
- else | ||
%li.breadcrumb-item | ||
= link_to('Attributes', index_attribs_path) | ||
%li.breadcrumb-item.active{ 'aria-current' => 'page' } | ||
- case request.path | ||
- when new_attribs_path(@project, @package) | ||
Add | ||
- when edit_attribs_path(@project, @package, @attribute.fullname) | ||
= @attribute.fullname |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
- 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(errors.count, 'error')} prohibited this attribute from being saved:" | ||
%ul | ||
- errors.full_messages.each do |message| | ||
%li= message | ||
|
||
#values | ||
= form.fields_for :values do |value| | ||
= render('value_fields', { f: value }.merge(value_fields_locals)) | ||
- if attribute.values_addable? | ||
%p | ||
= link_to_add_association(form, :values, render_options: { locals: value_fields_locals }, title: 'Add a value') do | ||
%i.fas.fa-plus-square | ||
Add a value | ||
- if issue_trackers | ||
#issues | ||
= form.fields_for :issues do |issue| | ||
= render('issue_fields', { f: issue }.merge(issue_fields_locals)) | ||
%p | ||
= link_to_add_association(form, :issues, render_options: { locals: issue_fields_locals }, title: 'Add an issue') do | ||
%i.fas.fa-plus-square | ||
Add an issue | ||
|
||
= form.submit('Save', class: 'btn btn-primary') | ||
= link_to('Back', index_attribs_path, class: 'btn btn-secondary', role: 'button') |
11 changes: 11 additions & 0 deletions
11
src/api/app/views/webui2/webui/attribute/_issue_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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.nested-fields | ||
.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-minus-circle |
19 changes: 19 additions & 0 deletions
19
src/api/app/views/webui2/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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.nested-fields | ||
.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-minus-circle |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- @pagetitle = "Edit Attribute #{@attribute.fullname} on #{@container.class} #{@container.name}" | ||
|
||
.card | ||
= render(partial: 'webui/package/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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
- @pagetitle = "Attributes of #{@package} (Project #{@project})" | ||
- package_bread_crumb 'Attributes' | ||
|
||
.card | ||
= render(partial: 'webui/package/tabs', locals: { project: @project, package: @package }) | ||
|
||
.card-body | ||
%h3= @pagetitle | ||
- if @attributes.present? | ||
.table-responsive | ||
%table.table.table-hover#attributes | ||
%thead.thead-light | ||
%tr | ||
%th.col-auto{ scope: 'col' } Attributes | ||
%th.col{ scope: 'col' } Values | ||
- if policy(@package).update? | ||
%th.col-auto{ scope: 'col' } Actions | ||
%tbody | ||
- @attributes.each do |attribute| | ||
%tr | ||
%td= 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 policy(@package).update? | ||
%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 | ||
= link_to(attrib_path(attribute), | ||
data: { confirm: "Delete attribute '#{attribute.fullname}'?" }, | ||
method: :delete, | ||
title: 'Delete attribute') do | ||
%i.fas.fa-minus-circle | ||
- else | ||
%p | ||
%em No attributes set | ||
|
||
- if policy(@package).update? | ||
%p | ||
= link_to(new_attribs_path(project: @project.name, package: @package), title: 'Add a new attribute') do | ||
%i.fas.fa-plus-square | ||
Add a new attribute |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- @pagetitle = 'Add Attribute' | ||
|
||
.card | ||
= render(partial: 'webui/package/tabs', locals: { project: @project, package: @package }) | ||
|
||
.card-body | ||
%h3= @pagetitle | ||
= form_for(@attribute) do |form| | ||
.form-row.form-group | ||
= form.hidden_field(:project_id) | ||
- if @attribute.package_id | ||
= form.hidden_field(:package_id) | ||
.col-auto | ||
= form.collection_select(:attrib_type_id, @attribute_types, :id, :fullname, {}, class: 'form-control') | ||
.col.col-form-label | ||
- @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' | ||
= form.submit('Add', class: 'btn btn-primary') | ||
= link_to('Back', index_attribs_path, class: 'btn btn-secondary', role: 'button') |