diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/referentials_controller.rb | 9 | ||||
| -rw-r--r-- | app/models/referential.rb | 22 | ||||
| -rw-r--r-- | app/views/referentials/show.html.slim | 17 |
3 files changed, 35 insertions, 13 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 09d990752..28a95c784 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -27,6 +27,15 @@ class ReferentialsController < BreadcrumbController end end + def archive + referential.archive! + redirect_to referential_path, notice: t('notice.referential.archived') + end + def unarchive + referential.unarchive! + redirect_to referential_path, notice: t('notice.referential.unarchived') + end + protected alias_method :referential, :resource diff --git a/app/models/referential.rb b/app/models/referential.rb index 51168a55f..d4bdc8374 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -208,20 +208,18 @@ class Referential < ActiveRecord::Base GeoRuby::SimpleFeatures::Geometry.from_ewkt(bounds.present? ? bounds : default_bounds ).envelope end + # Archive def archived? - true if !archived_at.nil? + archived_at != nil end - alias_method :archived, :archived? - def archived=(state) - state = [true, "1"].include?(state) - self.archived_at = (state ? Time.now : nil) + def archive! + # self.archived = true + touch :archived_at end - - def archive - self.archived = true - end - def unarchive - self.archived = false + def unarchive! + # self.archived = false + update_column :archived_at, nil end -end + +end
\ No newline at end of file diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index 1405d4dd2..d5fed0344 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -1,4 +1,6 @@ -= title_tag @referential.name +h2 + = @referential.name + em.small = " (archivé)" if @referential.archived? .summary p @@ -49,6 +51,19 @@ - content_for :sidebar do ul.actions li = link_to t('referentials.actions.edit'), edit_referential_path(@referential), class: 'edit' + + li + - if @referential.archived? + = link_to unarchive_referential_path(@referential), method: :put do + span.fa-stack + span.fa.fa-archive.fa-stack-1x + span.fa.fa-ban.fa-stack-2x + = " Désarchiver cet espace de données" + - else + = link_to archive_referential_path(@referential), method: :put do + span.fa.fa-archive + = " Archiver cet espace de données" + li = link_to t('referentials.actions.destroy'), referential_path(@referential), method: :delete, data: {:confirm => t('referentials.actions.destroy_confirm')}, class: "remove" li = link_to t('api_keys.actions.new'), new_referential_api_key_path(@referential), class: 'add' br |
