diff options
| -rw-r--r-- | app/controllers/calendars_controller.rb | 32 | ||||
| -rw-r--r-- | app/helpers/table_builder_helper/url.rb | 2 | ||||
| -rw-r--r-- | app/views/calendars/_form.html.slim | 53 |
3 files changed, 86 insertions, 1 deletions
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 75d4cbd09..cc160a98e 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -1,4 +1,5 @@ class CalendarsController < ChouetteController + include WorkgroupSupport include PolicyChecker include TimeTablesHelper @@ -54,10 +55,18 @@ class CalendarsController < ChouetteController private def decorate_calendars(calendars) +<<<<<<< HEAD CalendarDecorator.decorate( calendars, context: { workgroup: workgroup +======= + ModelDecorator.decorate( + calendars, + with: CalendarDecorator, + context: { + workgroup: current_workgroup +>>>>>>> update calendar build_links for table builder } ) end @@ -82,17 +91,30 @@ class CalendarsController < ChouetteController helper_method :workgroup def resource +<<<<<<< HEAD @calendar ||= workgroup.calendars.where('(organisation_id = ? OR shared = ?)', current_organisation.id, true).find_by_id(params[:id]) +======= +<<<<<<< HEAD + @calendar = Calendar.where('organisation_id = ? OR shared = true', current_organisation.id).find_by_id(params[:id]).decorate +======= + @calendar = Calendar.where('(organisation_id = ? OR shared = ?) AND workgroup_id = ?', current_organisation.id).find_by_id(params[:id], true, @workgroup.id) +>>>>>>> update calendar build_links for table builder +>>>>>>> update calendar build_links for table builder end def build_resource super.tap do |calendar| +<<<<<<< HEAD calendar.workgroup = workgroup +======= + calendar.workgroup = current_workgroup +>>>>>>> update calendar build_links for table builder calendar.organisation = current_organisation end end def collection +<<<<<<< HEAD @calendars ||= begin scope = workgroup.calendars.where('(organisation_id = ? OR shared = ?)', current_organisation.id, true) scope = shared_scope(scope) @@ -101,6 +123,16 @@ class CalendarsController < ChouetteController calendars = calendars.order(sort_column + ' ' + sort_direction) if sort_column && sort_direction calendars = calendars.paginate(page: params[:page]) end +======= + return @calendars if @calendars + scope = Calendar.where('(organisation_id = ? OR shared = ?) AND workgroup_id = ?', current_organisation.id, true, @workgroup.id) + scope = shared_scope(scope) + @q = scope.ransack(params[:q]) + + calendars = @q.result + calendars = calendars.order(sort_column + ' ' + sort_direction) if sort_column && sort_direction + @calendars = calendars.paginate(page: params[:page]) +>>>>>>> update calendar build_links for table builder end def ransack_contains_date diff --git a/app/helpers/table_builder_helper/url.rb b/app/helpers/table_builder_helper/url.rb index 57172301c..0e3dce0aa 100644 --- a/app/helpers/table_builder_helper/url.rb +++ b/app/helpers/table_builder_helper/url.rb @@ -3,7 +3,7 @@ module TableBuilderHelper def self.polymorphic_url_parts(item, referential, workgroup) polymorph_url = [] - unless item.is_a?(Referential) || item.is_a?(ComplianceControlSet) + unless item.is_a?(Calendar) || item.is_a?(Referential) || item.is_a?(ComplianceControlSet) if referential polymorph_url << referential polymorph_url << item.line if item.respond_to? :line diff --git a/app/views/calendars/_form.html.slim b/app/views/calendars/_form.html.slim new file mode 100644 index 000000000..bf9f4f3a7 --- /dev/null +++ b/app/views/calendars/_form.html.slim @@ -0,0 +1,53 @@ += simple_form_for [@workgroup, @calendar], html: { class: 'form-horizontal', id: 'calendar_form' }, wrapper: :horizontal_form do |f| + .row + .col-lg-12 + = f.input :name + = f.input :short_name + + - if policy(@calendar).share? + .form-group.has_switch + = f.label :shared, class: 'col-sm-4 col-xs-5 control-label' + = f.input :shared, as: :boolean, checked_value: true, unchecked_value: false, label: content_tag(:span, t("#{@calendar.shared}"), class: 'switch-label', data: {checkedValue: t('true'), uncheckedValue: t('false')}), wrapper_html: { class: 'col-sm-8 col-xs-7'} + + .separator + + .row + .col-lg-12 + .subform + .nested-head + .wrapper + div + .form-group + label.control-label + = Calendar.human_attribute_name(:date) + div + + = f.simple_fields_for :date_values do |date_value| + = render 'date_value_fields', f: date_value + + .links.nested-linker + = link_to_add_association t('simple_form.labels.calendar.add_a_date'), f, :date_values, class: 'btn btn-outline-primary' + + .separator + + .row + .col-lg-12 + .subform + .nested-head + .wrapper + div + .form-group + label.control-label + = t('simple_form.labels.calendar.ranges.begin') + div + .form-group + label.control-label + = t('simple_form.labels.calendar.ranges.end') + div + + = f.simple_fields_for :periods do |period| + = render 'period_fields', f: period + .links.nested-linker + = link_to_add_association t('simple_form.labels.calendar.add_a_date_range'), f, :periods, class: 'btn btn-outline-primary' + + = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'calendar_form' |
