-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Management features for field groups
- Loading branch information
Ben Tillman
committed
Dec 6, 2011
1 parent
ed8f456
commit 27f4e0b
Showing
19 changed files
with
143 additions
and
58 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
= form_for([:admin, @field_group], :html => one_submit_only(:field_group), :remote => true) do |f| | ||
= link_to_close edit_admin_field_group_path(@field_group) | ||
= f.error_messages | ||
= render :partial => "top_section", :locals => { :f => f, :edit => true } | ||
.buttonbar | ||
= f.submit t(:save_field_group), :id => :field_group_submit | ||
or | ||
= link_to_cancel edit_admin_field_group_path(@field_group) |
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,21 @@ | ||
.field_group[field_group] | ||
.title_tools | ||
= link_to_inline(:create_field, new_admin_field_path(:field_group_id => field_group.id), :text => t(:create_custom_field)) | ||
- edit_form_id = dom_id(field_group, :edit) | ||
- create_form_id = dom_id(field_group, :create_field) | ||
|
||
.title | ||
.subtitle_tools | ||
= link_to_inline(edit_form_id, edit_admin_field_group_path(field_group), :text => t(:edit_field_group)) | ||
| | ||
= link_to_inline(create_form_id, new_admin_field_path(:field_group_id => field_group.id), :text => t(:create_field)) | ||
|
||
.subtitle{ :id => "#{dom_id(field_group)}_title" } | ||
= t(field_group.name, :default => field_group.label) | ||
|
||
- group_list_id = "field_group_#{field_group.id}_fields" | ||
.list{ :id => group_list_id } | ||
.remote{ hidden.merge(:id => edit_form_id) } | ||
.remote{ hidden.merge(:id => create_form_id) } | ||
|
||
- list_id = dom_id(field_group, :fields) | ||
.list{ :id => list_id } | ||
- if (fields = field_group.fields).present? | ||
= render :partial => "admin/fields/field", :collection => fields | ||
|
||
= sortable_element(group_list_id, :url => sort_admin_fields_path(:field_group_id => field_group.id), :containment => group_list_ids, :dropOnEmpty => true) | ||
= sortable_element(list_id, :url => sort_admin_fields_path(:field_group_id => field_group.id), :containment => group_list_ids, :dropOnEmpty => true) |
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,9 +1,10 @@ | ||
- path = new_admin_field_group_path(:klass_name => @field_group.klass_name) | ||
|
||
= form_for([:admin, @field_group], :html => one_submit_only(:field_group), :remote => true) do |f| | ||
= link_to_close new_admin_field_group_path | ||
= link_to_close path | ||
= f.error_messages | ||
= render :partial => "admin/field_groups/top_section", :locals => { :f => f } | ||
= render :partial => "top_section", :locals => { :f => f } | ||
.buttonbar | ||
= f.submit "Create field group" | ||
= f.submit t(:create_field_group), :id => :field_group_submit | ||
or | ||
= link_to_cancel new_admin_field_group_path | ||
= link_to_cancel path |
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
asset = @field_group.klass_name.downcase | ||
id = "#{asset}_create_field_group" | ||
container_id = "#{asset}_field_groups" | ||
|
||
if @field_group.valid? | ||
page[:create_field_group_arrow].replace_html "►" | ||
page.visual_effect :toggle_blind, :create_field_group, :duration => 0.3, :afterFinish => 'function(effect) {effect.element.update("")}' | ||
asset_list_id = "#{@field_group.klass_name.downcase}_field_groups" | ||
page.insert_html :bottom, asset_list_id, :partial => "field_group", :collection => [ @field_group ] | ||
page["#{id}_arrow"].replace_html "►" | ||
page.visual_effect :toggle_blind, id, :duration => 0.3, :afterFinish => 'function(effect) {effect.element.update("")}' | ||
group_list_ids = @field_group.klass.field_groups.map {|field_group| dom_id(field_group, :fields)} | ||
page.insert_html :top, container_id, :partial => "field_group", :collection => [ @field_group ], :locals => {:group_list_ids => group_list_ids} | ||
page.insert_html :bottom, container_id, sortable_element(container_id, :url => sort_admin_field_groups_path(:asset => asset), :tag => :div) | ||
page[dom_id(@field_group)].visual_effect :highlight, :duration => 1.5 | ||
page.call "crm.flick", :empty, :remove | ||
page.insert_html :bottom, asset_list_id, sortable_element(asset_list_id, :url => sort_admin_field_groups_path(:asset => asset)) | ||
else | ||
page[:create_field_group].replace_html :partial => "new" | ||
page[:create_field_group].visual_effect :shake, :duration => 0.25, :distance => 6 | ||
page[:field_label].focus | ||
page[id].replace_html :partial => "new" | ||
page[id].visual_effect :shake, :duration => 0.25, :distance => 6 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
id = dom_id(@field_group) | ||
form_id = dom_id(@field_group, :edit) | ||
|
||
if params[:cancel] == "true" # <----------------- Hide [Edit field_group] | ||
|
||
page.call "crm.flip_form", form_id | ||
page.call "crm.set_title", id, @field_group.label | ||
|
||
else # <----------------------------------------- Show [Edit field_group] form. | ||
|
||
page.call "crm.show_form", form_id | ||
page[form_id].replace_html :partial => "edit" | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
asset = @field_group.klass_name.downcase | ||
id = "#{asset}_create_field_group" | ||
|
||
page.call "crm.flick", :empty, :toggle | ||
page.call "crm.flip_form", :create_field_group | ||
page.call "crm.flip_form", id | ||
|
||
if params[:cancel] != "true" | ||
page[:create_field_group].replace_html :partial => "new" | ||
page.call "crm.set_title", :create_field_group | ||
else | ||
page.call "crm.set_title", :create_field_group, "Custom field groups" | ||
page[id].replace_html :partial => "new" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
id = dom_id(@field_group, :edit) | ||
|
||
if @field_group.errors.empty? | ||
page.call "crm.flip_form", id | ||
page.call "crm.set_title", dom_id(@field_group), @field_group.label | ||
else | ||
page[id].replace_html :partial => "edit" | ||
page[id].visual_effect :shake, :duration => 0.25, :distance => 6 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
- path = new_admin_field_path(:field_group_id => @field.field_group_id) | ||
|
||
= form_for([:admin, @field], :as => :field, :html => one_submit_only(:field), :remote => true) do |f| | ||
= link_to_close new_admin_field_path | ||
= link_to_close path | ||
= f.error_messages | ||
= render :partial => "admin/fields/top_section", :locals => { :f => f } | ||
= render :partial => "top_section", :locals => { :f => f } | ||
.buttonbar | ||
= f.submit "Create field" | ||
= f.submit t(:create_field), :id => :field_submit | ||
or | ||
= link_to_cancel new_admin_field_path | ||
= link_to_cancel path |
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,16 @@ | ||
id = dom_id(@field.field_group, :create_field) | ||
container_id = dom_id(@field.field_group, :fields) | ||
|
||
if @field.valid? | ||
page[:create_field_arrow].replace_html "►" | ||
page[:create_field_title].replace_html "fields" | ||
page.visual_effect :toggle_blind, :create_field, :duration => 0.3, :afterFinish => 'function(effect) {effect.element.update("")}' | ||
group_list_id = "field_group_#{@field.field_group_id}_fields" | ||
page.insert_html :bottom, group_list_id, :partial => "field", :collection => [ @field ] | ||
page["#{id}_arrow"].replace_html "►" | ||
page.visual_effect :toggle_blind, id, :duration => 0.3, :afterFinish => 'function(effect) {effect.element.update("")}' | ||
page.insert_html :top, container_id, :partial => "field", :collection => [ @field ] | ||
page.insert_html :bottom, container_id, sortable_element(container_id, :url => sort_admin_fields_path(:field_group_id => @field.field_group_id)) | ||
page[dom_id(@field)].visual_effect :highlight, :duration => 1.5 | ||
page.call "crm.flick", :empty, :remove | ||
page.insert_html :bottom, group_list_id, sortable_element(group_list_id, :url => sort_admin_fields_path(:field_group_id => @field.field_group_id)) | ||
else | ||
page[:create_field].replace_html :partial => "new" | ||
page[:create_field].visual_effect :shake, :duration => 0.25, :distance => 6 | ||
page[id].replace_html :partial => "new" | ||
page[id].visual_effect :shake, :duration => 0.25, :distance => 6 | ||
page[:field_label].focus | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
id = dom_id(@field.field_group, :create_field) | ||
|
||
page.call "crm.flick", :empty, :toggle | ||
page.call "crm.flip_form", :create_field | ||
page.call "crm.flip_form", id | ||
|
||
if params[:cancel] != "true" | ||
page[:create_field].replace_html :partial => "new" | ||
page.call "crm.set_title", :create_field | ||
else | ||
page.call "crm.set_title", :create_field, "Custom fields" | ||
page[id].replace_html :partial => "new" | ||
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