suggest default zones
This commit is contained in:
parent
b13e77650e
commit
1bda86be03
3 changed files with 13 additions and 3 deletions
|
@ -81,6 +81,12 @@
|
|||
}
|
||||
|
||||
// Move checkbox to the top-left side of the label
|
||||
&.editable-champ-checkbox {
|
||||
label.admin-default-zone {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
&.editable-champ-checkbox {
|
||||
p,
|
||||
label {
|
||||
|
|
|
@ -27,8 +27,8 @@ class Zone < ApplicationRecord
|
|||
label_at(date) != 'Non attribué'
|
||||
end
|
||||
|
||||
def self.available_at(date)
|
||||
Zone.all.filter { |zone| zone.available_at?(date) }.sort_by { |zone| zone.label_at(date) }
|
||||
def self.available_at(date, without_zones = [])
|
||||
(Zone.all - without_zones).filter { |zone| zone.available_at?(date) }.sort_by { |zone| zone.label_at(date) }
|
||||
.map do |zone|
|
||||
OpenStruct.new(id: zone.id, label: zone.label_at(date))
|
||||
end
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
= f.label :zone do
|
||||
= t('zone', scope: 'activerecord.attributes.procedure')
|
||||
- if Rails.application.config.ds_zonage_enabled
|
||||
= f.collection_check_boxes :zone_ids, Zone.available_at(@procedure.published_or_created_at), :id, :label do |b|
|
||||
= f.collection_check_boxes :zone_ids, current_administrateur.default_zones, :id, :current_label do |b|
|
||||
.editable-champ.editable-champ-checkbox
|
||||
= b.check_box
|
||||
= b.label class: "admin-default-zone"
|
||||
= f.collection_check_boxes :zone_ids, Zone.available_at(@procedure.published_or_created_at, current_administrateur.default_zones), :id, :label do |b|
|
||||
.editable-champ.editable-champ-checkbox
|
||||
= b.check_box
|
||||
= b.label
|
||||
|
|
Loading…
Reference in a new issue