aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_public_body_categories_controller.rb8
-rw-r--r--app/controllers/admin_public_body_headings_controller.rb11
-rw-r--r--app/views/admin_public_body_categories/_form.html.erb25
-rw-r--r--app/views/admin_public_body_categories/_heading_list.html.erb9
-rw-r--r--app/views/admin_public_body_categories/edit.html.erb49
-rw-r--r--app/views/admin_public_body_categories/new.html.erb14
-rw-r--r--app/views/admin_public_body_headings/edit.html.erb53
-rw-r--r--app/views/admin_public_body_headings/new.html.erb14
8 files changed, 98 insertions, 85 deletions
diff --git a/app/controllers/admin_public_body_categories_controller.rb b/app/controllers/admin_public_body_categories_controller.rb
index fda09fa4a..5e305dde3 100644
--- a/app/controllers/admin_public_body_categories_controller.rb
+++ b/app/controllers/admin_public_body_categories_controller.rb
@@ -22,7 +22,8 @@ class AdminPublicBodyCategoriesController < AdminController
I18n.with_locale(I18n.default_locale) do
if params[:public_body_category][:category_tag] && PublicBody.find_by_tag(@category.category_tag).count > 0 && @category.category_tag != params[:public_body_category][:category_tag]
- flash[:notice] = 'There are authorities associated with this category, so the tag can\'t be renamed'
+ flash[:error] = "There are authorities associated with this category, so the tag can't be renamed"
+ render :action => 'edit'
else
if params[:headings]
heading_ids = params[:headings].values
@@ -48,10 +49,11 @@ class AdminPublicBodyCategoriesController < AdminController
if @category.update_attributes(params[:public_body_category])
flash[:notice] = 'Category was successfully updated.'
+ redirect_to edit_admin_category_path(@category)
+ else
+ render :action => 'edit'
end
end
-
- render :action => 'edit'
end
end
diff --git a/app/controllers/admin_public_body_headings_controller.rb b/app/controllers/admin_public_body_headings_controller.rb
index c7c80e802..e893e760d 100644
--- a/app/controllers/admin_public_body_headings_controller.rb
+++ b/app/controllers/admin_public_body_headings_controller.rb
@@ -10,8 +10,10 @@ class AdminPublicBodyHeadingsController < AdminController
@heading = PublicBodyHeading.find(params[:id])
if @heading.update_attributes(params[:public_body_heading])
flash[:notice] = 'Category heading was successfully updated.'
+ redirect_to edit_admin_heading_path(@heading)
+ else
+ render :action => 'edit'
end
- render :action => 'edit'
end
end
@@ -54,13 +56,6 @@ class AdminPublicBodyHeadingsController < AdminController
@locale = self.locale_from_params()
I18n.with_locale(@locale) do
heading = PublicBodyHeading.find(params[:id])
-
- if heading.public_body_categories.count > 0
- flash[:notice] = "There are categories associated with this heading, so can't destroy it"
- redirect_to edit_admin_heading_url(heading)
- return
- end
-
heading.destroy
flash[:notice] = "Category heading was successfully destroyed."
redirect_to admin_categories_url
diff --git a/app/views/admin_public_body_categories/_form.html.erb b/app/views/admin_public_body_categories/_form.html.erb
index b0778d371..1f033ac9b 100644
--- a/app/views/admin_public_body_categories/_form.html.erb
+++ b/app/views/admin_public_body_categories/_form.html.erb
@@ -44,16 +44,23 @@ end
</div>
</div>
-<% if PublicBody.find_by_tag(@category.category_tag).count == 0 or @category.errors.messages.keys.include?(:category_tag) %>
- <h3>Common Fields</h3>
+<h3>Common Fields</h3>
- <div class="control-group">
- <label for="public_body_category_category_tag" class="control-label">Category tag</label>
- <div class="controls">
- <%= f.text_field :category_tag, :class => "span4" %>
- </div>
- </div>
-<% end %>
+<div class="control-group">
+ <label for="public_body_category_category_tag" class="control-label">Category tag</label>
+ <div class="controls">
+ <% if PublicBody.find_by_tag(@category.category_tag).count == 0 or
+ @category.errors.messages.keys.include?(:category_tag) %>
+ <%= f.text_field :category_tag, :class => "span4" %>
+ <% else %>
+ <%= f.text_field :category_tag, :class => "span4", :disabled => true %>
+ <span class="help-block">
+ This Category already has authorities assigned to it so the tags
+ cannot be modified.
+ </span>
+ <% end %>
+ </div>
+</div>
<h3>Headings</h3>
<div class="control-group">
diff --git a/app/views/admin_public_body_categories/_heading_list.html.erb b/app/views/admin_public_body_categories/_heading_list.html.erb
index 4bd8bdc90..f92f0c9b0 100644
--- a/app/views/admin_public_body_categories/_heading_list.html.erb
+++ b/app/views/admin_public_body_categories/_heading_list.html.erb
@@ -1,9 +1,12 @@
<div class="accordion" id="category_list">
- <% for heading in category_headings %>
- <div class="accordion-group" data-id="headings_<%=heading.id%>">
+ <% category_headings.each do |heading| %>
+ <div class="accordion-group" data-id="headings_<%= heading.id %>">
<div class="accordion-heading accordion-toggle row">
<span class="item-title span6">
- <a href="#heading_<%=heading.id%>_categories" data-toggle="collapse" data-parent="#categories" ><%= chevron_right %></a>
+ <a href="#heading_<%= heading.id %>_categories" data-toggle="collapse" data-parent="#categories">
+ <span class="badge"><%= heading.public_body_categories.size %></span>
+ <%= chevron_right %>
+ </a>
<strong><%= link_to(heading.name, edit_admin_heading_path(heading), :title => "view full details") %></strong>
</span>
</div>
diff --git a/app/views/admin_public_body_categories/edit.html.erb b/app/views/admin_public_body_categories/edit.html.erb
index 95988d688..f83d0768d 100644
--- a/app/views/admin_public_body_categories/edit.html.erb
+++ b/app/views/admin_public_body_categories/edit.html.erb
@@ -1,30 +1,35 @@
-<h1><%=@title%></h1>
+<h1><%= @title %></h1>
<div class="row">
- <div class="span8">
- <div id="public_body_category_form">
- <%= form_for @category, :url => admin_category_path(@category), :html => { :class => "form form-horizontal" } do |f| %>
- <%= render :partial => 'form', :locals => {:f => f} %>
- <div class="form-actions">
- <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %></p>
- </div>
- <% end %>
- </div>
-</div>
+ <div class="span8">
+ <div id="public_body_category_form">
+ <%= form_for @category, :url => admin_category_path(@category), :html => { :class => "form form-horizontal" } do |f| %>
+ <%= render :partial => 'form', :locals => { :f => f } %>
-<div class="row">
- <div class="span8 well">
- <%= link_to 'List all', admin_categories_path, :class => "btn" %>
+ <div class="form-actions">
+ <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %>
+ <%= link_to 'List all', admin_categories_path, :class => "btn" %>
+ </div>
+ <% end %>
+ </div>
</div>
</div>
-<% if @tagged_public_bodies.empty? %>
- <div class="row">
- <div class="span8">
- <%= form_tag(admin_category_path(@category), :method => 'delete', :class => "form form-inline") do %>
- <%= hidden_field_tag(:public_body_id, { :value => @category.id } ) %>
- <%= submit_tag "Destroy #{@category.title}", :title => @category.title, :class => "btn btn-danger" %> (this is permanent!)
- <% end %>
+<hr />
+
+<div class="row">
+ <div class="span12">
+ <div class="well">
+ <%= form_for @category, :url => admin_category_path(@category), :method => 'delete', :class => "form form-inline" do |f| %>
+ <%= f.submit "Destroy #{ @category.title }",
+ :title => @category.title,
+ :class => "btn btn-danger",
+ :confirm => 'Are you sure?' %>
+ <span class="help-block">
+ Destroying a category does not destroy the public authorities
+ associated with the category.
+ </span>
+ <% end %>
</div>
</div>
-<% end %>
+</div>
diff --git a/app/views/admin_public_body_categories/new.html.erb b/app/views/admin_public_body_categories/new.html.erb
index 8b1b1103f..ed9f06d7c 100644
--- a/app/views/admin_public_body_categories/new.html.erb
+++ b/app/views/admin_public_body_categories/new.html.erb
@@ -1,21 +1,17 @@
<% @title = 'New category' %>
-<h1><%=@title%></h1>
+<h1><%= @title %></h1>
<div class="row">
<div class="span8">
<div id="public_category_form">
- <%= form_for @category, :url => admin_categories_path, :html => {:class => "form form-horizontal"} do |f| %>
- <%= render :partial => 'form', :locals => {:f => f} %>
+ <%= form_for @category, :url => admin_categories_path, :html => { :class => "form form-horizontal" } do |f| %>
+ <%= render :partial => 'form', :locals => { :f => f } %>
<div class="form-actions">
<%= f.submit "Create", :class => "btn btn-primary" %>
+ <%= link_to 'List all', admin_categories_path, :class => "btn" %>
</div>
- <% end %>
- <div class="row">
- <div class="span8 well">
- <%= link_to 'List all', admin_categories_path, :class => "btn" %>
- </div>
- </div>
+ <% end %>
</div>
</div>
</div>
diff --git a/app/views/admin_public_body_headings/edit.html.erb b/app/views/admin_public_body_headings/edit.html.erb
index eff89285a..d4bc02562 100644
--- a/app/views/admin_public_body_headings/edit.html.erb
+++ b/app/views/admin_public_body_headings/edit.html.erb
@@ -1,30 +1,39 @@
-<h1><%=@title%></h1>
+<h1><%= @title %></h1>
<div class="row">
- <div class="span8">
- <div id="public_body_heading_form">
- <%= form_for @heading, :url => admin_heading_path(@heading), :html => { :class => "form form-horizontal" } do |f| %>
- <%= render :partial => 'form', :locals => {:f => f} %>
- <div class="form-actions">
- <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %></p>
- </div>
- <% end %>
- </div>
-</div>
+ <div class="span8">
+ <div id="public_body_heading_form">
+ <%= form_for @heading, :url => admin_heading_path(@heading), :html => { :class => "form form-horizontal" } do |f| %>
+ <%= render :partial => 'form', :locals => { :f => f } %>
-<div class="row">
- <div class="span8 well">
- <%= link_to 'List all', admin_categories_path, :class => "btn" %>
- </div>
+ <div class="form-actions">
+ <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %>
+ <%= link_to 'List all', admin_categories_path, :class => "btn" %>
+ </div>
+ <% end %>
+ </div>
+ </div>
</div>
-<% if @heading.public_body_categories.empty? %>
- <div class="row">
- <div class="span8">
- <%= form_tag(admin_heading_path(@heading), :method => 'delete', :class => "form form-inline") do %>
- <%= hidden_field_tag(:public_body_heading_id, { :value => @heading.id } ) %>
- <%= submit_tag "Destroy #{@heading.name}", :name => @heading.name, :class => "btn btn-danger" %> (this is permanent!)
+<hr />
+
+<div class="row">
+ <div class="span12">
+ <div class="well">
+ <%= form_for @heading, :url => admin_heading_path(@heading), :method => 'delete', :class => "form form-inline" do |f| %>
+ <%= f.submit "Destroy #{ @heading.name }",
+ :name => @heading.name,
+ :class => "btn btn-danger",
+ :confirm => 'Are you sure?' %>
+ <span class="help-block">
+ <ul>
+ <li>Destroying a category heading only destroys the heading itself.</li>
+ <li>Child categories assigned to another heading remain assigned to the other heading.</li>
+ <li>Child categories with no other heading become "Categories with no heading".</li>
+ <li>Public authorities remain assigned to the categories.</li>
+ </ul>
+ </span>
<% end %>
</div>
</div>
-<% end %>
+</div>
diff --git a/app/views/admin_public_body_headings/new.html.erb b/app/views/admin_public_body_headings/new.html.erb
index 91d5d4a9d..c6fe514b0 100644
--- a/app/views/admin_public_body_headings/new.html.erb
+++ b/app/views/admin_public_body_headings/new.html.erb
@@ -1,21 +1,17 @@
<% @title = 'New category heading' %>
-<h1><%=@title%></h1>
+<h1><%= @title %></h1>
<div class="row">
<div class="span8">
<div id="public_heading_form">
- <%= form_for @heading, :url => admin_headings_path, :html => {:class => "form form-horizontal"} do |f| %>
- <%= render :partial => 'form', :locals => {:f => f} %>
+ <%= form_for @heading, :url => admin_headings_path, :html => { :class => "form form-horizontal" } do |f| %>
+ <%= render :partial => 'form', :locals => { :f => f } %>
<div class="form-actions">
<%= f.submit "Create", :class => "btn btn-primary" %>
+ <%= link_to 'List all', admin_categories_path, :class => "btn" %>
</div>
- <% end %>
- <div class="row">
- <div class="span8 well">
- <%= link_to 'List all', admin_categories_path, :class => "btn" %>
- </div>
- </div>
+ <% end %>
</div>
</div>
</div>