-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add collection selection UI to edit forms
This change adds the code necessary to allow administrators to set a field's data_type to `vocabulary` and have the edit form display a list of availabel collections in a selection dropdown. Right now, the `vocabulary` data_type only supports collections, but we hope to generalize the funcionality to other controlled vocabularies in the future.
- Loading branch information
Showing
9 changed files
with
119 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,41 @@ | ||
.item input, .item textarea { | ||
width: 50rem; | ||
display: block; | ||
} | ||
.item { | ||
input, textarea { | ||
width: 50rem; | ||
display: block; | ||
} | ||
|
||
select { | ||
width: 35rem; | ||
margin-right: 2rem; | ||
height: 1.9rem; | ||
} | ||
|
||
button.delete_value { | ||
width: 13rem; | ||
} | ||
|
||
button.add_value { | ||
display: block; | ||
margin-top: 0.25rem; | ||
} | ||
|
||
.item .required { | ||
font-style: italic; | ||
.required { | ||
font-style: italic; | ||
} | ||
|
||
label { | ||
margin-bottom: 0.5rem; | ||
} | ||
} | ||
|
||
#choose_blueprint button { | ||
display: block; | ||
margin-bottom: 0.25rem; | ||
#choose_blueprint { | ||
width: fit-content; | ||
|
||
button { | ||
display: block; | ||
width: 100%; | ||
margin-bottom: 0.25rem; | ||
} | ||
} | ||
|
||
|
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,15 +1,15 @@ | ||
# Custom form controls to support T3 field-specific data types | ||
# e.g. #vacabulary provides a customized select populated with a defined vocabulary | ||
class T3FormBuilder < ActionView::Helpers::FormBuilder | ||
def vocabulary(method, options = {}) | ||
def vocabulary_field(method, options = {}) | ||
multiple = options.delete(:multiple) | ||
selected = options.delete(:value) || '' | ||
select_options = options.except(:multiple) | ||
.reverse_merge( | ||
{ name: @template.field_name(@object_name, method, multiple: multiple) } | ||
) | ||
.merge({ selected: selected }) | ||
option_tags = @template.options_from_collection_for_select(Collection.order(:created_at), :id, :id, selected) | ||
option_tags = @template.options_from_collection_for_select(Collection.order(:created_at), :label, :label, selected) | ||
select(method, option_tags, { prompt: 'Select one', selected: '', disabled: true }, select_options) | ||
end | ||
end |
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
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
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
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