Skip to content

Commit

Permalink
added deprecate form
Browse files Browse the repository at this point in the history
  • Loading branch information
luisgreg99 committed Jan 13, 2016
1 parent 8c375fa commit 72ebbab
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/controllers/terms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def edit
@term = term_form_repository.find(params[:id])
end

def deprecate
@term = term_form_repository.find(params[:id])
end

def update
edit_term_form = term_form_repository.find(params[:id])
edit_term_form.attributes = term_params
Expand Down
7 changes: 6 additions & 1 deletion app/models/term.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Term < ActiveTriples::Resource
configure :repository => :default
property :label, :predicate => RDF::RDFS.label
property :comment, :predicate => RDF::RDFS.comment
property :is_replaced_by, :predicate => RDF::DC.isReplacedBy
property :issued, :predicate => RDF::DC.issued
property :modified, :predicate => RDF::DC.modified
delegate :vocabulary_id, :leaf, :to => :term_uri, :prefix => true
Expand All @@ -25,7 +26,11 @@ def repository
end

def editable_fields
fields - [:issued, :modified]
fields - [:issued, :modified, :is_replaced_by]
end

def editable_fields_deprecate
fields - [:issued, :modified, :label, :comment]
end

def to_param
Expand Down
5 changes: 5 additions & 0 deletions app/views/terms/_deprecate_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p><%= term.rdf_subject %></p>
<% term.editable_fields_deprecate.each do |attribute| %>
<%= render :partial => "vocabularies/form_attribute", :locals => {:vocabulary => term, :attribute => attribute, :form => f} %>
<% end %>
<%= f.button :submit, "Deprecate" %>
5 changes: 5 additions & 0 deletions app/views/terms/deprecate.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>Deprecate Term</h1>

<%= simple_form_for(@term, :url => update_term_path(:id => @term.id)) do |f| %>
<%= render "deprecate_form", :f => f, :term => @term %>
<% end %>
3 changes: 3 additions & 0 deletions app/views/terms/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

<%= simple_form_for(@term, :url => update_term_path(:id => @term.id)) do |f| %>
<%= render "edit_form", :f => f, :term => @term %>
<%= link_to "Deprecate", polymorphic_path([@term], :action => 'deprecate'), :class => 'btn btn-default' %>
<% end %>

1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
get '/vocabularies/*vocabulary_id/new', :to => "terms#new", :as => "new_term"
resources :terms, :only => [:create]
get 'terms/*id/edit', :to => "terms#edit", :as => "edit_term"
get 'terms/*id/deprecate', :to => "terms#deprecate", :as => "deprecate_term"

get "/import_rdf", :to => "import_rdf#index", :as => "import_rdf_form"
post "/import_rdf", :to => "import_rdf#import", :as => "import_rdf"
Expand Down

0 comments on commit 72ebbab

Please sign in to comment.