-
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.
- Loading branch information
Ben Tillman
committed
Dec 6, 2011
1 parent
fa2d852
commit ed8f456
Showing
16 changed files
with
185 additions
and
47 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
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,3 @@ | ||
// Place all the styles related to the Admin::FieldGroups controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,65 @@ | ||
# Fat Free CRM | ||
# Copyright (C) 2008-2011 by Michael Dvorkin | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
#------------------------------------------------------------------------------ | ||
|
||
class Admin::FieldGroupsController < Admin::ApplicationController | ||
before_filter :require_user | ||
|
||
# GET /field_groups/new | ||
# GET /field_groups/new.xml AJAX | ||
#---------------------------------------------------------------------------- | ||
def new | ||
@field_group = FieldGroup.new(:klass_name => params[:klass_name]) | ||
|
||
respond_to do |format| | ||
format.js # new.js.rjs | ||
format.xml { render :xml => @field_group } | ||
end | ||
|
||
rescue ActiveRecord::RecordNotFound | ||
respond_to_not_found(:html, :xml) | ||
end | ||
|
||
# POST /field_groups | ||
# POST /field_groups.xml AJAX | ||
#---------------------------------------------------------------------------- | ||
def create | ||
@field_group = FieldGroup.new(params[:field_group]) | ||
|
||
respond_to do |format| | ||
if @field_group.save | ||
format.js # create.js.rjs | ||
format.xml { render :xml => @field_group, :status => :created, :location => @field_group } | ||
else | ||
format.js # create.js.rjs | ||
format.xml { render :xml => @field_group.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# POST /field_groups/sort | ||
#---------------------------------------------------------------------------- | ||
def sort | ||
asset = params[:asset] | ||
field_group_ids = params["#{asset}_field_groups"] | ||
|
||
field_group_ids.each_with_index do |id, index| | ||
FieldGroup.update_all({:position => index+1}, {:id => id}) | ||
end | ||
|
||
render :nothing => true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Admin::FieldGroupsHelper | ||
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,13 @@ | ||
.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)) | ||
|
||
.title | ||
= t(field_group.name, :default => field_group.label) | ||
|
||
- group_list_id = "field_group_#{field_group.id}_fields" | ||
.list{ :id => group_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) |
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 @@ | ||
|
||
= form_for([:admin, @field_group], :html => one_submit_only(:field_group), :remote => true) do |f| | ||
= link_to_close new_admin_field_group_path | ||
= f.error_messages | ||
= render :partial => "admin/field_groups/top_section", :locals => { :f => f } | ||
.buttonbar | ||
= f.submit "Create field group" | ||
or | ||
= link_to_cancel new_admin_field_group_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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.section | ||
= f.hidden_field :klass_name | ||
|
||
%table | ||
%tr | ||
%td | ||
.label.top.req Label: | ||
= f.text_field :label | ||
%td= spacer | ||
%td | ||
.label.top.req Tag: | ||
= f.select :tag_id, ActsAsTaggableOn::Tag.all.map { |tag| [tag.name, tag.id] } |
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 @@ | ||
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[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 | ||
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 @@ | ||
page.call "crm.flick", :empty, :toggle | ||
page.call "crm.flip_form", :create_field_group | ||
|
||
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" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe Admin::FieldGroupsController do | ||
|
||
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,15 @@ | ||
require 'spec_helper' | ||
|
||
# Specs in this file have access to a helper object that includes | ||
# the Admin::FieldGroupsHelper. For example: | ||
# | ||
# describe Admin::FieldGroupsHelper do | ||
# describe "string concat" do | ||
# it "concats two strings with spaces" do | ||
# helper.concat_strings("this","that").should == "this that" | ||
# end | ||
# end | ||
# end | ||
describe Admin::FieldGroupsHelper do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |