From 584231357b00a89918fe8032c774dc1acfb692f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Fri, 9 Jun 2017 09:27:08 +0200 Subject: [PATCH 01/38] Add timer icon for new driver --- app/assets/javascripts/backend/interventions.js.coffee | 10 ++++++++-- .../backend/intervention_participations_controller.rb | 2 ++ .../_participations_modal.html.haml | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index f9dc653bb7..a4338b4327 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -192,11 +192,10 @@ i $('.feathers input[name*="nature"], .feathers input[name*="state"]').closest('.feather').show() showInterventionParticipationsModal: -> - $('.has-intervention-participations').on 'click', (event) -> + $(document).on 'click', '.has-intervention-participations', (event) -> intervention_id = $('input[name="intervention_id"]').val() product_id = $(event.target).closest('.nested-product-parameter').find(".scoped-parameter").attr('value') - # participation_id = $(event.target).attr('data-participation') $.ajax url: "/backend/intervention_participations/participations_modal", @@ -249,6 +248,13 @@ $(this).each -> E.interventions.updateAvailabilityInstant($(this).val()) + $(document).on "click", ".nested-doers .nested-add", (e) -> + nestedField = $('.nested-doers .nested-fields').last() + pictoTimer = $('
') + + $(nestedField).append(pictoTimer) + $(nestedField).find(".has-intervention-participations").trigger("click") + # $(document).on "click", '.view-toolbar a', (event) -> # E.interventions.hideKujakuFilters($(event.target).is('[data-janus-href="cobbles"]')) diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index b364c0165c..7d80d92cb2 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -53,6 +53,8 @@ def create intervention_id: permitted_params[:intervention_id] ) + participation.save if participation.new_record? + working_periods_ids = participation.working_periods.map(&:id) params_ids = permitted_params[:working_periods_attributes].to_h.map { |param| param.second['id'].to_i } diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 8db3f1abe6..ecd9dc351c 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -1,4 +1,5 @@ -= modal_header("Temps de travaux de \"#{ participation.product.name }\"") +- product_name = participation.product.nil? ? "" : participation.product.name += modal_header("Temps de travaux de \"#{ product_name }\"") = simple_form_for(participation, url: backend_intervention_participations_path, method: :post, remote: true) do |f| = hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id From 19fffd4d349923e91f8372f9db103ba2bdfd3787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Fri, 9 Jun 2017 11:56:22 +0200 Subject: [PATCH 02/38] Resolve firefox date bug --- .../intervention_participations/_participations_modal.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index ecd9dc351c..12040f4c3b 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -4,7 +4,7 @@ = simple_form_for(participation, url: backend_intervention_participations_path, method: :post, remote: true) do |f| = hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id = hidden_field_tag "intervention_participation[product_id]", participation.product_id - = hidden_field_tag 'intervention_started_at', participation.intervention.started_at + = hidden_field_tag 'intervention_started_at', participation.intervention.started_at.iso8601 .modal-body .indicators From f8784da37ccbea405302d782df5f5b822a5314ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Wed, 28 Jun 2017 11:51:49 +0200 Subject: [PATCH 03/38] Change modal validation --- .../intervention_participations.js.coffee | 47 ++++++++-- .../backend/interventions.js.coffee | 2 +- .../backend/interventions_controller.rb | 14 +++ app/models/intervention.rb | 2 +- .../_participations_modal.html.haml | 94 +++++++++---------- .../_working_periods_fields.html.haml | 10 +- 6 files changed, 106 insertions(+), 63 deletions(-) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index ed03201740..e87520f0e3 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -27,9 +27,9 @@ newLine = $('
') - $(newLine).append('') - $(newLine).append('') - $(newLine).append('') + $(newLine).append('') + $(newLine).append('') + $(newLine).append('') participation_icon = $('
') $(participation_icon).append('
') @@ -39,12 +39,12 @@ $(newLine).append('
') hour_field = $('
') - $(hour_field).append('') + $(hour_field).append('') $(hour_field).append('H') $(newLine).find('.participation-form').append(hour_field) min_field = $('
') - $(min_field).append('') + $(min_field).append('') $(min_field).append('Min') $(newLine).find('.participation-form').append(min_field) @@ -63,12 +63,45 @@ return - $(document).on "submit", '.edit_intervention_participation', (event) -> + $(document).on "submit", '.edit_intervention_participation, .new_intervention_participation', (event) -> + event.preventDefault() + event.stopImmediatePropagation() + + @workingTimesModal = new ekylibre.modal('#working_times') + @workingTimesModal.getModal().modal 'hide' + + return false + + $(document).on 'click', '#validParticipationsForm', (event) -> + element = $(event.target) + + participation = new Object() + participation.intervention_id = $('#intervention_participation_intervention_id').val() + participation.product_id = $('#intervention_participation_product_id').val() + + workingPeriods = [] + participations = $('.participation') + + $('.participation').each -> + workingPeriod = new Object() + workingPeriod.nature = $(this).find('input[name="working_period_nature"]').val() + workingPeriod.started_at = $(this).find('input[name="working_period_started_at"]').val() + workingPeriod.stopped_at = $(this).find('input[name="working_period_stopped_at"]').val() + + workingPeriods.push(workingPeriod) + + participation.working_periods = workingPeriods + jsonParticipation = JSON.stringify(participation) + + participationsCount = $('input[name="intervention-participation"]').length + + $('.edit_intervention .form-fields').append('') + @workingTimesModal = new ekylibre.modal('#working_times') @workingTimesModal.getModal().modal 'hide' - $(document).on "change", '#working_times .participations input[type="text"]', (event) -> + $(document).on "keyup", '#working_times .participations input[type="text"]', (event) -> element = $(event.target) E.interventionParticipations.changeWorkingPeriod(element) diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index 2a07b20af5..8b9a2b2612 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -187,7 +187,7 @@ if hideFilters $('.feathers input[name*="nature"], .feathers input[name*="state"]').closest('.feather').hide() else - i $('.feathers input[name*="nature"], .feathers input[name*="state"]').closest('.feather').show() + $('.feathers input[name*="nature"], .feathers input[name*="state"]').closest('.feather').show() showInterventionParticipationsModal: -> $(document).on 'click', '.has-intervention-participations', (event) -> diff --git a/app/controllers/backend/interventions_controller.rb b/app/controllers/backend/interventions_controller.rb index 516e376335..d828cf9220 100644 --- a/app/controllers/backend/interventions_controller.rb +++ b/app/controllers/backend/interventions_controller.rb @@ -257,6 +257,20 @@ def new render(locals: { cancel_url: { action: :index }, with_continue: true }) end + + def update + byebug + permitted_params[:participations_attributes] = JSON.parse(permitted_params[:participations_attributes]) + + @intervention = find_and_check + + # if @intervention.update_attributes(**permitted_params.symbolize_keys) + if @intervention.update_attributes(permitted_params) + redirect_to :show + else + render :edit + end + end def sell interventions = params[:id].split(',') diff --git a/app/models/intervention.rb b/app/models/intervention.rb index b0cbdd794c..883a3b8bc1 100644 --- a/app/models/intervention.rb +++ b/app/models/intervention.rb @@ -108,7 +108,7 @@ class Intervention < Ekylibre::Record::Base calculable period: :month, column: :working_duration, at: :started_at, name: :sum acts_as_numbered - accepts_nested_attributes_for :group_parameters, :doers, :inputs, :outputs, :targets, :tools, :working_periods, allow_destroy: true + accepts_nested_attributes_for :group_parameters, :participations, :doers, :inputs, :outputs, :targets, :tools, :working_periods, allow_destroy: true accepts_nested_attributes_for :labellings, allow_destroy: true scope :between, lambda { |started_at, stopped_at| diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 12040f4c3b..921b7f9556 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -1,52 +1,48 @@ - product_name = participation.product.nil? ? "" : participation.product.name = modal_header("Temps de travaux de \"#{ product_name }\"") -= simple_form_for(participation, url: backend_intervention_participations_path, method: :post, remote: true) do |f| - = hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id - = hidden_field_tag "intervention_participation[product_id]", participation.product_id - = hidden_field_tag 'intervention_started_at', participation.intervention.started_at.iso8601 - - .modal-body - .indicators - .med-info - %span.title= Intervention.human_attribute_name(:started_at) - %span.value - %i.picto.picto-clock-o - = participation.intervention.started_at.l(format: :compact) - - .participations - .participations-header - %h3{ class: "action-header action-period" }= :action_duration.tl - %h3{ class: "action-header" }= :calculated_hours.tl - - - = f.simple_fields_for :working_periods do |working_periods_form| - - working_period = working_periods_form.object - = render 'working_periods_fields', { f: working_periods_form, index: working_periods_form.index, working_period: working_period } - - - if working_period.pause_next? - - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) - = render 'working_periods_fields', { index: working_periods_form.index + 1, working_period: pause_period } - - - .actions - = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :preparation } do - =image_tag('intervention_participations/action-preparation.svg', class: "action-icon") - %span= I18n.t('enumerize.intervention_working_period.nature.preparation') - - = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :travel } do - =image_tag('intervention_participations/action-travel.svg', class: "action-icon") - %span= I18n.t('enumerize.intervention_working_period.nature.travel') - - = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :intervention } do - =image_tag('intervention_participations/action-intervention.svg', class: "action-icon") - %span= I18n.t('enumerize.intervention_working_period.nature.intervention') - - = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :pause } do - .picto.picto-pause-circle-outline - %span= I18n.t('enumerize.intervention_working_period.nature.pause') - - - .modal-footer - = submit_tag 'Valider', class: "btn btn-primary" - = submit_tag :cancel.tl, type: :button, class: "btn btn-default", data: { dismiss: 'modal' } += hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id += hidden_field_tag "intervention_participation[product_id]", participation.product_id += hidden_field_tag 'intervention_started_at', participation.intervention.started_at.iso8601 + +.modal-body + .indicators + .med-info + %span.title= Intervention.human_attribute_name(:started_at) + %span.value + %i.picto.picto-clock-o + = participation.intervention.started_at.l(format: :compact) + + .participations + .participations-header + %h3{ class: "action-header action-period" }= :action_duration.tl + %h3{ class: "action-header" }= :calculated_hours.tl + + - participation.working_periods.each do |working_period| + = render 'working_periods_fields', { working_period: working_period } + + - if working_period.pause_next? + - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) + = render 'working_periods_fields', { working_period: pause_period } + + .actions + = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :preparation } do + =image_tag('intervention_participations/action-preparation.svg', class: "action-icon") + %span= I18n.t('enumerize.intervention_working_period.nature.preparation') + + = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :travel } do + =image_tag('intervention_participations/action-travel.svg', class: "action-icon") + %span= I18n.t('enumerize.intervention_working_period.nature.travel') + + = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :intervention } do + =image_tag('intervention_participations/action-intervention.svg', class: "action-icon") + %span= I18n.t('enumerize.intervention_working_period.nature.intervention') + + = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :pause } do + .picto.picto-pause-circle-outline + %span= I18n.t('enumerize.intervention_working_period.nature.pause') + + +.modal-footer + = button_tag :valid.tl, class: "btn btn-primary", id: "validParticipationsForm" + = button_tag :cancel.tl, class: "btn btn-default", data: { dismiss: 'modal' } diff --git a/app/views/backend/intervention_participations/_working_periods_fields.html.haml b/app/views/backend/intervention_participations/_working_periods_fields.html.haml index 5e05273e6e..6704edec45 100644 --- a/app/views/backend/intervention_participations/_working_periods_fields.html.haml +++ b/app/views/backend/intervention_participations/_working_periods_fields.html.haml @@ -5,9 +5,9 @@ .participation = hidden_field_tag 'working_period_id', working_period.id - = hidden_field_tag "#{working_periods_attributes}[#{index}][nature]", working_period.nature, data: { 'is-nature-hidden-field': true } - = hidden_field_tag "#{working_periods_attributes}[#{index}][started_at]", working_period.started_at.l(format: :full), data: { 'is-hours-hidden-field': true } - = hidden_field_tag "#{working_periods_attributes}[#{index}][stopped_at]", working_period.stopped_at.l(format: :full), data: { 'is-minutes-hidden-field': true } + = hidden_field_tag "working_period_nature", working_period.nature, data: { 'is-nature-hidden-field': true } + = hidden_field_tag "working_period_started_at", working_period.started_at.l(format: :full), data: { 'is-hours-hidden-field': true } + = hidden_field_tag "working_period_stopped_at", working_period.stopped_at.l(format: :full), data: { 'is-minutes-hidden-field': true } .participation-icon .picto.picto-timelapse @@ -15,11 +15,11 @@ .participation-form .participation-field - = text_field_tag "#{working_periods_attributes}[#{index}][hours]", working_period.hours_gap, { class: "participation-input", data: { 'is-hours-field': true }} + = text_field_tag "working_period_hours", working_period.hours_gap, { class: "participation-input", data: { 'is-hours-field': true }} %span H .participation-field - = text_field_tag "#{working_periods_attributes}[#{index}][minutes]", working_period.minutes_gap, { class: "participation-input", data: { 'is-minutes-field': true }} + = text_field_tag "working_period_minutes", working_period.minutes_gap, { class: "participation-input", data: { 'is-minutes-field': true }} %span Min .participation-result From 40bbbb86b6fa46ccd6c3cc92147e81c5e6cad28f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Wed, 5 Jul 2017 11:24:07 +0200 Subject: [PATCH 04/38] Rework of save / edit / delete intervention working periods --- .../intervention_participations.js.coffee | 14 ++------- .../backend/interventions_controller.rb | 31 ++++++++++++++++--- app/models/intervention_working_period.rb | 5 --- .../_participations_modal.html.haml | 1 + 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index e87520f0e3..0da3d95f3b 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -62,20 +62,11 @@ return - - $(document).on "submit", '.edit_intervention_participation, .new_intervention_participation', (event) -> - event.preventDefault() - event.stopImmediatePropagation() - - @workingTimesModal = new ekylibre.modal('#working_times') - @workingTimesModal.getModal().modal 'hide' - - return false - $(document).on 'click', '#validParticipationsForm', (event) -> element = $(event.target) participation = new Object() + participation.id = $('#intervention_participation_id').val() participation.intervention_id = $('#intervention_participation_intervention_id').val() participation.product_id = $('#intervention_participation_product_id').val() @@ -84,13 +75,14 @@ $('.participation').each -> workingPeriod = new Object() + workingPeriod.id= $(this).find('input[name="working_period_id"]').val() workingPeriod.nature = $(this).find('input[name="working_period_nature"]').val() workingPeriod.started_at = $(this).find('input[name="working_period_started_at"]').val() workingPeriod.stopped_at = $(this).find('input[name="working_period_stopped_at"]').val() workingPeriods.push(workingPeriod) - participation.working_periods = workingPeriods + participation.working_periods_attributes = workingPeriods jsonParticipation = JSON.stringify(participation) participationsCount = $('input[name="intervention-participation"]').length diff --git a/app/controllers/backend/interventions_controller.rb b/app/controllers/backend/interventions_controller.rb index d828cf9220..43296d7678 100644 --- a/app/controllers/backend/interventions_controller.rb +++ b/app/controllers/backend/interventions_controller.rb @@ -259,14 +259,17 @@ def new end def update - byebug - permitted_params[:participations_attributes] = JSON.parse(permitted_params[:participations_attributes]) + participations = permitted_params[:participations_attributes] + participations.inject(participations){ |hash, (key, value)| hash[key] = JSON.parse(value) } + + permitted_params[:participations_attributes] = participations @intervention = find_and_check - # if @intervention.update_attributes(**permitted_params.symbolize_keys) + delete_working_periods(participations) + if @intervention.update_attributes(permitted_params) - redirect_to :show + redirect_to action: :show else render :edit end @@ -425,6 +428,26 @@ def find_interventions interventions end + def delete_working_periods(form_participations) + working_periods_ids = form_participations + .values + .map{ |participation| participation["working_periods_attributes"].map{ |working_period| working_period["id"] }} + .flatten + .compact + .uniq + .map(&:to_i) + + saved_working_periods_ids = @intervention + .participations + .map{ |participation| participation.working_periods.map(&:id) } + .flatten + + working_periods_to_destroy = saved_working_periods_ids - working_periods_ids + InterventionWorkingPeriod.where(id: working_periods_to_destroy).destroy_all + + @intervention.reload + end + def state_change_permitted_params params.require(:intervention).permit(:interventions_ids, :state, :delete_option) end diff --git a/app/models/intervention_working_period.rb b/app/models/intervention_working_period.rb index d742c74a8d..f0f2382ef6 100644 --- a/app/models/intervention_working_period.rb +++ b/app/models/intervention_working_period.rb @@ -84,11 +84,6 @@ class InterventionWorkingPeriod < Ekylibre::Record::Base if started_at && stopped_at && stopped_at <= started_at errors.add(:stopped_at, :posterior, to: started_at.l) end - if intervention_participation.present? - siblings = intervention_participation.working_periods.where.not(id: id || 0) - errors.add(:started_at, :overlap_sibling) if siblings.where('started_at < ? AND ? < stopped_at', started_at, started_at).any? - errors.add(:stopped_at, :overlap_sibling) if siblings.where('started_at < ? AND ? < stopped_at', stopped_at, stopped_at).any? - end end after_commit :update_temporality, unless: -> { intervention.blank? } diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 921b7f9556..1ddde05d46 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -1,6 +1,7 @@ - product_name = participation.product.nil? ? "" : participation.product.name = modal_header("Temps de travaux de \"#{ product_name }\"") += hidden_field_tag "intervention_participation[id]", participation.id = hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id = hidden_field_tag "intervention_participation[product_id]", participation.product_id = hidden_field_tag 'intervention_started_at', participation.intervention.started_at.iso8601 From 6e6cfabfba704c2edbe65fdb310febf13473695f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Wed, 5 Jul 2017 16:53:07 +0200 Subject: [PATCH 05/38] Change code for allow to save multi working periods --- .../intervention_participations.js.coffee | 24 +++++++- .../backend/interventions.js.coffee | 19 ++++--- .../intervention_participations_controller.rb | 57 ++++--------------- .../backend/interventions_controller.rb | 4 +- .../tekyla/stylesheets/interventions.scss | 3 +- 5 files changed, 47 insertions(+), 60 deletions(-) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index 0da3d95f3b..c0634ef8ea 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -69,9 +69,11 @@ participation.id = $('#intervention_participation_id').val() participation.intervention_id = $('#intervention_participation_intervention_id').val() participation.product_id = $('#intervention_participation_product_id').val() + participation.state = "done" workingPeriods = [] participations = $('.participation') + has_one_full_participation = false $('.participation').each -> workingPeriod = new Object() @@ -80,15 +82,31 @@ workingPeriod.started_at = $(this).find('input[name="working_period_started_at"]').val() workingPeriod.stopped_at = $(this).find('input[name="working_period_stopped_at"]').val() + if workingPeriod.started_at != "" && workingPeriod.stopped_at != "" + has_one_full_participation = true + workingPeriods.push(workingPeriod) participation.working_periods_attributes = workingPeriods jsonParticipation = JSON.stringify(participation) - participationsCount = $('input[name="intervention-participation"]').length + participationsCount = $('input[type="hidden"].intervention-participation').length + existingParticipation = $('.intervention-participation[data-product-id="' + participation.product_id + '"]') + + if existingParticipation.length > 0 + existingParticipation.val(jsonParticipation) + else + $('.edit_intervention .form-fields').append('') + + + concernedProductField = $('.nested-doers .nested-fields .selector .selector-value[value="' + participation.product_id + '"]') + nestedFieldBlock = concernedProductField.closest('.nested-fields') + productFieldPicto = nestedFieldBlock.find('.picto-timer-off') + + if has_one_full_participation && productFieldPicto.length == 1 + productFieldPicto.removeClass('picto-timer-off') + productFieldPicto.addClass('picto-timer') - $('.edit_intervention .form-fields').append('') - @workingTimesModal = new ekylibre.modal('#working_times') @workingTimesModal.getModal().modal 'hide' diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index 8b9a2b2612..369a65d0ba 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -193,11 +193,12 @@ $(document).on 'click', '.has-intervention-participations', (event) -> intervention_id = $('input[name="intervention_id"]').val() - product_id = $(event.target).closest('.nested-product-parameter').find(".scoped-parameter").attr('value') + product_id = $(event.target).closest('.nested-product-parameter').find(".selector .selector-value").val() + existingParticipation = $('.intervention-participation[data-product-id="' + product_id + '"]').val() $.ajax url: "/backend/intervention_participations/participations_modal", - data: { intervention_id: intervention_id, product_id: product_id } + data: { intervention_id: intervention_id, product_id: product_id, existing_participation: existingParticipation } success: (data, status, request) -> @workingTimesModal = new ekylibre.modal('#working_times') @@ -273,22 +274,22 @@ $(this).each -> E.interventions.updateAvailabilityInstant($(this).val()) - $(document).on "click", ".nested-doers .nested-add", (e) -> - nestedField = $('.nested-doers .nested-fields').last() + + $(document).on "selector:change", 'input[data-selector-id="intervention_doer_product_id"]', (event) -> + element = $(event.target) + blockElement = element.closest('.nested-fields') + pictoTimer = $('
') - $(nestedField).append(pictoTimer) - $(nestedField).find(".has-intervention-participations").trigger("click") + $(blockElement).append(pictoTimer) - # $(document).on "click", '.view-toolbar a', (event) -> - # E.interventions.hideKujakuFilters($(event.target).is('[data-janus-href="cobbles"]')) $(document).ready -> # E.interventions.hideKujakuFilters($('.view-toolbar a[data-janus-href="cobbles"]').hasClass('active')) - if $('.edit_intervention').length > 0 + if $('.new_intervention, .edit_intervention').length > 0 E.interventions.showInterventionParticipationsModal() if $('.taskboard').length > 0 diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index 7d80d92cb2..0ddc414064 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -47,53 +47,18 @@ def convert end end - def create - participation = InterventionParticipation.find_or_initialize_by( - product_id: permitted_params[:product_id], - intervention_id: permitted_params[:intervention_id] - ) - - participation.save if participation.new_record? - - working_periods_ids = participation.working_periods.map(&:id) - params_ids = permitted_params[:working_periods_attributes].to_h.map { |param| param.second['id'].to_i } - - working_periods_to_destroy = working_periods_ids - params_ids - InterventionWorkingPeriod.where(id: working_periods_to_destroy).destroy_all - - permitted_params[:working_periods_attributes].values.each do |working_period_params| - nature = working_period_params[:nature] - started_at = Time.strptime(working_period_params[:started_at], t('time.formats.full')) - stopped_at = Time.strptime(working_period_params[:stopped_at], t('time.formats.full')) - - next if nature.to_sym == :pause - - if !working_period_params[:id].nil? - working_period = participation.working_periods.find(working_period_params[:id]) - working_period.started_at = started_at - working_period.stopped_at = stopped_at - working_period.save - else - participation.working_periods.create!( - started_at: started_at, - stopped_at: stopped_at, - nature: nature.to_sym - ) - end - end - - participation.save - - respond_to do |format| - format.js { render nothing: true } - end - end - def participations_modal - participation = InterventionParticipation.find_or_initialize_by( - product_id: params[:product_id], - intervention_id: params[:intervention_id] - ) + participation = nil + + if params["existing_participation"].present? + json_participation = JSON.parse(params['existing_participation']) + participation = InterventionParticipation.new(json_participation) + else + participation = InterventionParticipation.find_or_initialize_by( + product_id: params[:product_id], + intervention_id: params[:intervention_id] + ) + end render partial: 'backend/intervention_participations/participations_modal', locals: { participation: participation } end diff --git a/app/controllers/backend/interventions_controller.rb b/app/controllers/backend/interventions_controller.rb index 43296d7678..d48cf0a7a9 100644 --- a/app/controllers/backend/interventions_controller.rb +++ b/app/controllers/backend/interventions_controller.rb @@ -260,7 +260,9 @@ def new def update participations = permitted_params[:participations_attributes] - participations.inject(participations){ |hash, (key, value)| hash[key] = JSON.parse(value) } + participations.each_pair do |key, value| + participations[key] = JSON.parse(value) + end permitted_params[:participations_attributes] = participations diff --git a/app/themes/tekyla/stylesheets/interventions.scss b/app/themes/tekyla/stylesheets/interventions.scss index 5b9dd688ec..3c4c102b8b 100644 --- a/app/themes/tekyla/stylesheets/interventions.scss +++ b/app/themes/tekyla/stylesheets/interventions.scss @@ -145,7 +145,8 @@ $preview-modal-height: 80vh; } } -.edit_intervention { +.edit_intervention, +.new_intervention { .has-intervention-participations { position: relative; top: -$fs-large; From 12bc439af27852703008772aa8773c17013ca766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 6 Jul 2017 15:27:59 +0200 Subject: [PATCH 06/38] Fix intervention participations creation --- .../intervention_participations.js.coffee | 21 +++++---- .../backend/interventions.js.coffee | 6 ++- .../intervention_participations_controller.rb | 8 +++- .../backend/interventions_controller.rb | 45 ++++++++++++++----- .../_participations_modal.html.haml | 4 +- .../_product_parameter_fields.html.haml | 9 ++-- 6 files changed, 66 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index c0634ef8ea..f4bc7ac444 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -76,16 +76,19 @@ has_one_full_participation = false $('.participation').each -> - workingPeriod = new Object() - workingPeriod.id= $(this).find('input[name="working_period_id"]').val() - workingPeriod.nature = $(this).find('input[name="working_period_nature"]').val() - workingPeriod.started_at = $(this).find('input[name="working_period_started_at"]').val() - workingPeriod.stopped_at = $(this).find('input[name="working_period_stopped_at"]').val() + workingPeriodNature = $(this).find('input[name="working_period_nature"]').val() + + if workingPeriodNature != "pause" + workingPeriod = new Object() + workingPeriod.id= $(this).find('input[name="working_period_id"]').val() + workingPeriod.nature = workingPeriodNature + workingPeriod.started_at = $(this).find('input[name="working_period_started_at"]').val() + workingPeriod.stopped_at = $(this).find('input[name="working_period_stopped_at"]').val() - if workingPeriod.started_at != "" && workingPeriod.stopped_at != "" - has_one_full_participation = true + if workingPeriod.started_at != "" && workingPeriod.stopped_at != "" + has_one_full_participation = true - workingPeriods.push(workingPeriod) + workingPeriods.push(workingPeriod) participation.working_periods_attributes = workingPeriods jsonParticipation = JSON.stringify(participation) @@ -96,7 +99,7 @@ if existingParticipation.length > 0 existingParticipation.val(jsonParticipation) else - $('.edit_intervention .form-fields').append('') + $('.edit_intervention, .new_intervention').find('.form-fields').append('') concernedProductField = $('.nested-doers .nested-fields .selector .selector-value[value="' + participation.product_id + '"]') diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index 369a65d0ba..a2d59eea3d 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -195,10 +195,14 @@ intervention_id = $('input[name="intervention_id"]').val() product_id = $(event.target).closest('.nested-product-parameter').find(".selector .selector-value").val() existingParticipation = $('.intervention-participation[data-product-id="' + product_id + '"]').val() + interventionStartedAt = null + + if intervention_id == "" + interventionStartedAt = $('.intervention-started-at').val() $.ajax url: "/backend/intervention_participations/participations_modal", - data: { intervention_id: intervention_id, product_id: product_id, existing_participation: existingParticipation } + data: { intervention_id: intervention_id, product_id: product_id, existing_participation: existingParticipation, intervention_started_at: interventionStartedAt } success: (data, status, request) -> @workingTimesModal = new ekylibre.modal('#working_times') diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index 0ddc414064..d99801be68 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -60,7 +60,13 @@ def participations_modal ) end - render partial: 'backend/intervention_participations/participations_modal', locals: { participation: participation } + if participation.intervention.nil? + intervention_started_at = Time.parse(params["intervention_started_at"]) + else + intervention_started_at = participation.intervention.started_at + end + + render partial: 'backend/intervention_participations/participations_modal', locals: { participation: participation, intervention_started_at: intervention_started_at } end private diff --git a/app/controllers/backend/interventions_controller.rb b/app/controllers/backend/interventions_controller.rb index d48cf0a7a9..cfc73f181b 100644 --- a/app/controllers/backend/interventions_controller.rb +++ b/app/controllers/backend/interventions_controller.rb @@ -249,7 +249,7 @@ def new p.set! nil end - + @intervention = Intervention.new(options) from_request = Intervention.find_by(id: params[:request_intervention_id]) @@ -257,18 +257,43 @@ def new render(locals: { cancel_url: { action: :index }, with_continue: true }) end - - def update - participations = permitted_params[:participations_attributes] - participations.each_pair do |key, value| - participations[key] = JSON.parse(value) + + def create + unless permitted_params[:participations_attributes].nil? + participations = permitted_params[:participations_attributes] + + participations.each_pair do |key, value| + participations[key] = JSON.parse(value) + end + + permitted_params[:participations_attributes] = participations end - - permitted_params[:participations_attributes] = participations - @intervention = find_and_check + @intervention = Intervention.new(permitted_params) + + url = if params[:create_and_continue] + { action: :new, continue: true } + else + params[:redirect] || { action: :show, id: 'id'.c } + end - delete_working_periods(participations) + return if save_and_redirect(@intervention, url: url, notify: :record_x_created, identifier: :number) + render(locals: { cancel_url: { action: :index }, with_continue: true }) + end + + def update + @intervention = find_and_check + + unless permitted_params[:participations_attributes].nil? + participations = permitted_params[:participations_attributes] + participations.each_pair do |key, value| + participations[key] = JSON.parse(value) + end + + permitted_params[:participations_attributes] = participations + + delete_working_periods(participations) + end if @intervention.update_attributes(permitted_params) redirect_to action: :show diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 1ddde05d46..24494761a5 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -4,7 +4,7 @@ = hidden_field_tag "intervention_participation[id]", participation.id = hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id = hidden_field_tag "intervention_participation[product_id]", participation.product_id -= hidden_field_tag 'intervention_started_at', participation.intervention.started_at.iso8601 += hidden_field_tag 'intervention_started_at', intervention_started_at.iso8601 .modal-body .indicators @@ -12,7 +12,7 @@ %span.title= Intervention.human_attribute_name(:started_at) %span.value %i.picto.picto-clock-o - = participation.intervention.started_at.l(format: :compact) + = intervention_started_at.l(format: :compact) .participations .participations-header diff --git a/app/views/backend/interventions/_product_parameter_fields.html.haml b/app/views/backend/interventions/_product_parameter_fields.html.haml index 549a08b80b..63832b1555 100644 --- a/app/views/backend/interventions/_product_parameter_fields.html.haml +++ b/app/views/backend/interventions/_product_parameter_fields.html.haml @@ -16,11 +16,12 @@ = f.referenced_association :product, label: reference.human_name, source: { scope: reference.scope_hash.merge(availables: [at: started_at.strftime("%Y-%m-%d %H:%M")]), keep: true }, input_html: { class: "scoped-parameter", data: { intervention_updater: prefix + 'product_id' } }, new: false - - if !f.object.new_record? && reference.doer? - - participation_picto = f.object.participation.nil? ? 'timer-off' : 'timer' - - datas = { participation: f.object.participation.id } unless f.object.participation.nil? + - if reference.doer? + - if !f.object.new_record? + - participation_picto = f.object.participation.nil? ? 'timer-off' : 'timer' + - datas = { participation: f.object.participation.id } unless f.object.participation.nil? + %div{ class: "has-intervention-participations picto picto-#{participation_picto}", data: datas } - %div{ class: "has-intervention-participations picto picto-#{participation_picto}", data: datas } = modal(id: "working_times", class: "working-times", size: :large) do .modal-body .modal-footer From bae68de06d7e62b4c6470a77733c776bc46e6193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 6 Jul 2017 15:55:26 +0200 Subject: [PATCH 07/38] Add times for tools and remove prepare time for tractors --- app/views/backend/interventions/_product_parameter.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/backend/interventions/_product_parameter.html.haml b/app/views/backend/interventions/_product_parameter.html.haml index 69103e2219..6e1c347472 100644 --- a/app/views/backend/interventions/_product_parameter.html.haml +++ b/app/views/backend/interventions/_product_parameter.html.haml @@ -9,7 +9,7 @@ - participation = product_parameter.participation if product_parameter.is_a?(InterventionDoer) - is_equipment = product.try(:tractor?) || product.try(:self_prepelled_equipment?) .periods - - if (!participation.nil? && participation.has_period_with_nature?(nature: :preparation)) || is_equipment + - if (!participation.nil? && participation.has_period_with_nature?(nature: :preparation)) .period .period-type = image_tag('intervention_participations/action-preparation.svg', class: "period-icon") @@ -23,7 +23,7 @@ %h3{ class: "period-label" } Déplacement = add_working_period_cost(product_parameter, nature: :travel) - - if (!participation.nil? && participation.has_period_with_nature?(nature: :intervention)) || is_equipment + - if (!participation.nil? && participation.has_period_with_nature?(nature: :intervention)) || product.is_a?(Equipment) .period .period-type = image_tag('intervention_participations/action-intervention.svg', class: "period-icon") From c9b4457a4a4946b028b45d2727bd1226eb0dbbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Fri, 7 Jul 2017 09:43:42 +0200 Subject: [PATCH 08/38] Remove prepare times from tools total --- app/models/intervention_tool.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/intervention_tool.rb b/app/models/intervention_tool.rb index 6fbe5022ea..d17f25ee5f 100644 --- a/app/models/intervention_tool.rb +++ b/app/models/intervention_tool.rb @@ -60,12 +60,8 @@ class InterventionTool < InterventionAgent def working_duration(nature: nil) tractors_count = InterventionParameter.of_variety(intervention.id, :tractor).count prepelled_equipments_count = InterventionParameter.of_variety(intervention.id, :self_prepelled_equipment).count - - drivers_times = if nature.nil? - intervention.drivers_times(not_nature: :travel) - else - intervention.drivers_times(nature: nature) - end + + drivers_times = intervention.drivers_times(nature: :intervention) if intervention.participations.empty? || drivers_times == 0 || (tractors_count == 0 && prepelled_equipments_count == 0) return intervention_working_duration From 6431ceb4f44ee0fe0a0a516f7189e85a2c2a36f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Mon, 10 Jul 2017 16:40:47 +0200 Subject: [PATCH 09/38] Clean codes and labels --- .../intervention_participations.js.coffee | 4 +-- .../backend/interventions.js.coffee | 2 +- .../backend/interventions_controller.rb | 36 +++++++++---------- app/models/activity.rb | 1 + app/models/animal.rb | 1 + app/models/animal_group.rb | 1 + app/models/bioproduct.rb | 1 + app/models/building.rb | 1 + app/models/building_division.rb | 1 + app/models/cultivable_zone.rb | 1 + app/models/easement.rb | 1 + app/models/equipment.rb | 1 + app/models/equipment_fleet.rb | 1 + app/models/fungus.rb | 1 + app/models/integration.rb | 1 + app/models/intervention_tool.rb | 4 +-- app/models/land_parcel.rb | 1 + app/models/matter.rb | 1 + app/models/plant.rb | 1 + app/models/product.rb | 1 + app/models/product_group.rb | 1 + app/models/settlement.rb | 1 + app/models/sub_zone.rb | 1 + app/models/worker.rb | 2 +- app/models/zone.rb | 1 + .../_participations_modal.html.haml | 7 ++-- .../_working_periods_fields.html.haml | 4 +-- .../_product_parameter.html.haml | 10 +++--- config/locales/arb/action.yml | 4 +++ config/locales/arb/enumerize.yml | 1 + config/locales/cmn/action.yml | 4 +++ config/locales/cmn/enumerize.yml | 1 + config/locales/deu/action.yml | 4 +++ config/locales/deu/enumerize.yml | 1 + config/locales/eng/action.yml | 11 +++--- config/locales/eng/enumerize.yml | 2 +- config/locales/eng/models.yml | 1 + config/locales/fra/action.yml | 3 ++ config/locales/fra/enumerize.yml | 2 +- config/locales/ita/action.yml | 4 +++ config/locales/ita/enumerize.yml | 1 + config/locales/jpn/action.yml | 4 +++ config/locales/jpn/enumerize.yml | 1 + config/locales/por/action.yml | 4 +++ config/locales/por/enumerize.yml | 1 + config/locales/spa/action.yml | 4 +++ config/locales/spa/enumerize.yml | 1 + config/rights.yml | 2 ++ db/tables.yml | 8 +++++ test/fixtures/activities.yml | 1 + test/fixtures/cultivable_zones.yml | 1 + test/fixtures/integrations.yml | 1 + test/fixtures/products.yml | 1 + test/models/activity_test.rb | 1 + test/models/animal_group_test.rb | 1 + test/models/animal_test.rb | 1 + test/models/bioproduct_test.rb | 1 + test/models/building_division_test.rb | 1 + test/models/building_test.rb | 1 + test/models/cultivable_zone_test.rb | 1 + test/models/easement_test.rb | 1 + test/models/equipment_fleet_test.rb | 1 + test/models/equipment_test.rb | 1 + test/models/fungus_test.rb | 1 + test/models/integration_test.rb | 1 + test/models/land_parcel_test.rb | 1 + test/models/matter_test.rb | 1 + test/models/plant_test.rb | 1 + test/models/product_group_test.rb | 1 + test/models/product_test.rb | 1 + test/models/settlement_test.rb | 1 + test/models/sub_zone_test.rb | 1 + test/models/worker_test.rb | 1 + test/models/zone_test.rb | 1 + 74 files changed, 138 insertions(+), 40 deletions(-) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index f4bc7ac444..326e873e8f 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -77,7 +77,7 @@ $('.participation').each -> workingPeriodNature = $(this).find('input[name="working_period_nature"]').val() - + if workingPeriodNature != "pause" workingPeriod = new Object() workingPeriod.id= $(this).find('input[name="working_period_id"]').val() @@ -100,7 +100,7 @@ existingParticipation.val(jsonParticipation) else $('.edit_intervention, .new_intervention').find('.form-fields').append('') - + concernedProductField = $('.nested-doers .nested-fields .selector .selector-value[value="' + participation.product_id + '"]') nestedFieldBlock = concernedProductField.closest('.nested-fields') diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index a2d59eea3d..3b5656b6c5 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -282,7 +282,7 @@ $(document).on "selector:change", 'input[data-selector-id="intervention_doer_product_id"]', (event) -> element = $(event.target) blockElement = element.closest('.nested-fields') - + pictoTimer = $('
') $(blockElement).append(pictoTimer) diff --git a/app/controllers/backend/interventions_controller.rb b/app/controllers/backend/interventions_controller.rb index cfc73f181b..36dcd8e3c6 100644 --- a/app/controllers/backend/interventions_controller.rb +++ b/app/controllers/backend/interventions_controller.rb @@ -249,7 +249,7 @@ def new p.set! nil end - + @intervention = Intervention.new(options) from_request = Intervention.find_by(id: params[:request_intervention_id]) @@ -261,11 +261,11 @@ def new def create unless permitted_params[:participations_attributes].nil? participations = permitted_params[:participations_attributes] - + participations.each_pair do |key, value| participations[key] = JSON.parse(value) end - + permitted_params[:participations_attributes] = participations end @@ -280,18 +280,18 @@ def create return if save_and_redirect(@intervention, url: url, notify: :record_x_created, identifier: :number) render(locals: { cancel_url: { action: :index }, with_continue: true }) end - + def update @intervention = find_and_check - + unless permitted_params[:participations_attributes].nil? participations = permitted_params[:participations_attributes] participations.each_pair do |key, value| participations[key] = JSON.parse(value) end - + permitted_params[:participations_attributes] = participations - + delete_working_periods(participations) end @@ -457,18 +457,18 @@ def find_interventions def delete_working_periods(form_participations) working_periods_ids = form_participations - .values - .map{ |participation| participation["working_periods_attributes"].map{ |working_period| working_period["id"] }} - .flatten - .compact - .uniq - .map(&:to_i) - + .values + .map { |participation| participation['working_periods_attributes'].map { |working_period| working_period['id'] } } + .flatten + .compact + .uniq + .map(&:to_i) + saved_working_periods_ids = @intervention - .participations - .map{ |participation| participation.working_periods.map(&:id) } - .flatten - + .participations + .map { |participation| participation.working_periods.map(&:id) } + .flatten + working_periods_to_destroy = saved_working_periods_ids - working_periods_ids InterventionWorkingPeriod.where(id: working_periods_to_destroy).destroy_all diff --git a/app/models/activity.rb b/app/models/activity.rb index 7e8aa5b45a..8618945561 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -22,6 +22,7 @@ # # == Table: activities # +# codes :jsonb # created_at :datetime not null # creator_id :integer # cultivation_variety :string diff --git a/app/models/animal.rb b/app/models/animal.rb index c2c46ca90a..adb9ccdbd5 100644 --- a/app/models/animal.rb +++ b/app/models/animal.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/animal_group.rb b/app/models/animal_group.rb index 8855588899..ad82d7848e 100644 --- a/app/models/animal_group.rb +++ b/app/models/animal_group.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/bioproduct.rb b/app/models/bioproduct.rb index 33eb9ad522..503b33df1f 100644 --- a/app/models/bioproduct.rb +++ b/app/models/bioproduct.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/building.rb b/app/models/building.rb index 84ee2aee7c..2cf3b7925d 100644 --- a/app/models/building.rb +++ b/app/models/building.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/building_division.rb b/app/models/building_division.rb index 2799b148f1..2dd80a3d90 100644 --- a/app/models/building_division.rb +++ b/app/models/building_division.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/cultivable_zone.rb b/app/models/cultivable_zone.rb index d8f2bcfbfb..6c0c0c5f6b 100644 --- a/app/models/cultivable_zone.rb +++ b/app/models/cultivable_zone.rb @@ -22,6 +22,7 @@ # # == Table: cultivable_zones # +# codes :jsonb # created_at :datetime not null # creator_id :integer # custom_fields :jsonb diff --git a/app/models/easement.rb b/app/models/easement.rb index b9d3ac5eef..9d461b92d8 100644 --- a/app/models/easement.rb +++ b/app/models/easement.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/equipment.rb b/app/models/equipment.rb index a2efef2390..41e99bfdce 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/equipment_fleet.rb b/app/models/equipment_fleet.rb index f660b8ec01..4947511cd5 100644 --- a/app/models/equipment_fleet.rb +++ b/app/models/equipment_fleet.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/fungus.rb b/app/models/fungus.rb index 4415db8790..2d0a85d2e8 100644 --- a/app/models/fungus.rb +++ b/app/models/fungus.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/integration.rb b/app/models/integration.rb index 672574d8dd..d481a8aa15 100644 --- a/app/models/integration.rb +++ b/app/models/integration.rb @@ -25,6 +25,7 @@ # ciphered_parameters :jsonb # created_at :datetime not null # creator_id :integer +# data :jsonb # id :integer not null, primary key # initialization_vectors :jsonb # lock_version :integer default(0), not null diff --git a/app/models/intervention_tool.rb b/app/models/intervention_tool.rb index d17f25ee5f..84fc2d1ed1 100644 --- a/app/models/intervention_tool.rb +++ b/app/models/intervention_tool.rb @@ -60,7 +60,7 @@ class InterventionTool < InterventionAgent def working_duration(nature: nil) tractors_count = InterventionParameter.of_variety(intervention.id, :tractor).count prepelled_equipments_count = InterventionParameter.of_variety(intervention.id, :self_prepelled_equipment).count - + drivers_times = intervention.drivers_times(nature: :intervention) if intervention.participations.empty? || drivers_times == 0 || (tractors_count == 0 && prepelled_equipments_count == 0) @@ -69,7 +69,7 @@ def working_duration(nature: nil) drivers_times / (tractors_count + prepelled_equipments_count) end - + def catalog_usage :travel_cost end diff --git a/app/models/land_parcel.rb b/app/models/land_parcel.rb index 466a427ed0..068abfb92c 100644 --- a/app/models/land_parcel.rb +++ b/app/models/land_parcel.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/matter.rb b/app/models/matter.rb index ebe0ad64d5..323b283cd0 100644 --- a/app/models/matter.rb +++ b/app/models/matter.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/plant.rb b/app/models/plant.rb index 916b6c675c..4a6bf2c9ee 100644 --- a/app/models/plant.rb +++ b/app/models/plant.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/product.rb b/app/models/product.rb index fb09cecbfd..206120bba4 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/product_group.rb b/app/models/product_group.rb index 640fce0668..db7c84ec94 100644 --- a/app/models/product_group.rb +++ b/app/models/product_group.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/settlement.rb b/app/models/settlement.rb index ed5f01d961..ae87dd7fcc 100644 --- a/app/models/settlement.rb +++ b/app/models/settlement.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/sub_zone.rb b/app/models/sub_zone.rb index 4002c283b4..fc415d0782 100644 --- a/app/models/sub_zone.rb +++ b/app/models/sub_zone.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/models/worker.rb b/app/models/worker.rb index cb68db3450..8e5049253a 100644 --- a/app/models/worker.rb +++ b/app/models/worker.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer @@ -95,7 +96,6 @@ class Worker < Product self.team_id = user.team_id if user && user.team end - def participation(intervention) InterventionParticipation.find_by(product: self, intervention: intervention) end diff --git a/app/models/zone.rb b/app/models/zone.rb index 4604c2b8f7..d465a93154 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 24494761a5..2473f9d4ae 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -1,10 +1,11 @@ - product_name = participation.product.nil? ? "" : participation.product.name -= modal_header("Temps de travaux de \"#{ product_name }\"") += modal_header(t('labels.working_times', name: product_name)) +=# modal_header("Temps de travaux de \"#{ product_name }\"") = hidden_field_tag "intervention_participation[id]", participation.id = hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id = hidden_field_tag "intervention_participation[product_id]", participation.product_id -= hidden_field_tag 'intervention_started_at', intervention_started_at.iso8601 += hidden_field_tag 'intervention_started_at', intervention_started_at.iso8601 .modal-body .indicators @@ -21,7 +22,7 @@ - participation.working_periods.each do |working_period| = render 'working_periods_fields', { working_period: working_period } - + - if working_period.pause_next? - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) = render 'working_periods_fields', { working_period: pause_period } diff --git a/app/views/backend/intervention_participations/_working_periods_fields.html.haml b/app/views/backend/intervention_participations/_working_periods_fields.html.haml index 6704edec45..7cb64fec9a 100644 --- a/app/views/backend/intervention_participations/_working_periods_fields.html.haml +++ b/app/views/backend/intervention_participations/_working_periods_fields.html.haml @@ -16,11 +16,11 @@ .participation-form .participation-field = text_field_tag "working_period_hours", working_period.hours_gap, { class: "participation-input", data: { 'is-hours-field': true }} - %span H + %span= t('labels.hours') .participation-field = text_field_tag "working_period_minutes", working_period.minutes_gap, { class: "participation-input", data: { 'is-minutes-field': true }} - %span Min + %span= t('labels.minutes') .participation-result %span{ class: "previous-working-date" }= working_period.started_at.l(format: :full) diff --git a/app/views/backend/interventions/_product_parameter.html.haml b/app/views/backend/interventions/_product_parameter.html.haml index 6e1c347472..8def7d6aa3 100644 --- a/app/views/backend/interventions/_product_parameter.html.haml +++ b/app/views/backend/interventions/_product_parameter.html.haml @@ -13,25 +13,25 @@ .period .period-type = image_tag('intervention_participations/action-preparation.svg', class: "period-icon") - %h3{ class: "period-label" } Préparation + %h3{ class: "period-label" }= t('enumerize.intervention_working_period.preparation') = add_working_period_cost(product_parameter, nature: :preparation) - if !participation.nil? && participation.has_period_with_nature?(nature: :travel) .period .period-type = image_tag('intervention_participations/action-travel.svg', class: "period-icon") - %h3{ class: "period-label" } Déplacement + %h3{ class: "period-label" }= t('enumerize.intervention_working_period.travel') = add_working_period_cost(product_parameter, nature: :travel) - - if (!participation.nil? && participation.has_period_with_nature?(nature: :intervention)) || product.is_a?(Equipment) + - if (!participation.nil? && participation.has_period_with_nature?(nature: :intervention)) || product.is_a?(Equipment) .period .period-type = image_tag('intervention_participations/action-intervention.svg', class: "period-icon") - %h3{ class: "period-label" } Intervention + %h3{ class: "period-label" }= t('enumerize.intervention_working_period.intervention') = add_working_period_cost(product_parameter, nature: :intervention) .total - %h3{ class: "total-label" } Total + %h3{ class: "total-label" }= t('labels.total') = add_total_working_period(product_parameter) - variant = product_parameter.variant diff --git a/config/locales/arb/action.yml b/config/locales/arb/action.yml index 82cd63eb7a..87689e4605 100644 --- a/config/locales/arb/action.yml +++ b/config/locales/arb/action.yml @@ -1507,6 +1507,7 @@ arb: one: "مجموع الوقت المستخدم : ساعة واحدة" #? other: "مجموع الوقت المستخدم%{count} ساعات" #? zero: "" #? + # hours: "H" human_working_duration: "مدة العمل" # humans: "HR" iban: "رقم الحساب المصرفي الدولي (IBAN)" @@ -1545,6 +1546,7 @@ arb: insert_actual_password: "أدخل كلمة المرور الحالية" #? insert_password: "أدخل كلمة المرور الجديدة" #? inspections: "عمليات التفتيش" + # interactive_maps: "A JS library for interactive maps" interface_preferences: "تفضيلات واجهة" internal_error: "عفوا، حدث شيء ما." international_normal_vat_collected: "معدل ضريبة القيمة المضافة الدولية العادية %8.5" #? @@ -1722,6 +1724,7 @@ arb: method: "طريقة" minimal_temperature: "درجة الحرارة الحد الأدنى" minimum_amount: "اقل مبلغ" + # minutes: "Min" missing_attributes: "بعض سمات مفقودة" missing_help: "صفحات مفقودة" mobile: "التليفون المحمول" @@ -2397,6 +2400,7 @@ arb: workers: "العمال" working_duration: "مدة العمل" working_sets_stocks: "مجموعات العمل الأسهم" + # working_times: "Working times of %{name}" x_cashes: one: "حساب بنكي واحد" other: "%{count} حسابات بنكية اخرى" diff --git a/config/locales/arb/enumerize.yml b/config/locales/arb/enumerize.yml index 17899d272e..816dbdcddc 100644 --- a/config/locales/arb/enumerize.yml +++ b/config/locales/arb/enumerize.yml @@ -94,6 +94,7 @@ arb: purchase: "شراء" sale: "تخفيض السعر" stock: "مخزون" + # travel_cost: "Travel" crumb: nature: hard_start: "البداية الصعبة" diff --git a/config/locales/cmn/action.yml b/config/locales/cmn/action.yml index 08c423ac82..45a13807ab 100644 --- a/config/locales/cmn/action.yml +++ b/config/locales/cmn/action.yml @@ -1127,6 +1127,7 @@ cmn: # hint: "Hint: %{value}" historic: "历史性" home: "家" + # hours: "H" human_working_duration: "工作时间" # humans: "HR" iban: "国际银行账户号码(IBAN)" @@ -1158,6 +1159,7 @@ cmn: input_cost_per_hectare: "每公顷投入成本" #? inputs: "输入" inspections: "检查" + # interactive_maps: "A JS library for interactive maps" interface_preferences: "界面首" internal_error: "哎呀,事情发生了。" interval: "个性化间隔" @@ -1275,6 +1277,7 @@ cmn: method: "方法" minimal_temperature: "最低温度" minimum_amount: "最低金额" + # minutes: "Min" missing_attributes: "有些属性丢失" missing_help: "缺页" mobile: "移动" @@ -1745,6 +1748,7 @@ cmn: workers: "工人" working_duration: "工作时间" working_sets_stocks: "工作集股" + # working_times: "Working times of %{name}" x_cashes: # one: "%{count} cash" # other: "%{count} cashes" diff --git a/config/locales/cmn/enumerize.yml b/config/locales/cmn/enumerize.yml index 45bdfae573..c3fede2ce4 100644 --- a/config/locales/cmn/enumerize.yml +++ b/config/locales/cmn/enumerize.yml @@ -94,6 +94,7 @@ cmn: purchase: "采购" sale: "拍卖" stock: "股票" + # travel_cost: "Travel" crumb: nature: hard_start: "硬启动" diff --git a/config/locales/deu/action.yml b/config/locales/deu/action.yml index cea9b8f126..6f7db60350 100644 --- a/config/locales/deu/action.yml +++ b/config/locales/deu/action.yml @@ -1127,6 +1127,7 @@ deu: # hint: "Hint: %{value}" historic: "historisch" home: "Zuhause" + # hours: "H" human_working_duration: "Arbeitsdauer" # humans: "HR" iban: "Internationale Bankkontonummer (IBAN)" @@ -1158,6 +1159,7 @@ deu: input_cost_per_hectare: "Inputkosten pro Hektar" #? inputs: "Eingänge" inspections: "Inspektionen" + # interactive_maps: "A JS library for interactive maps" interface_preferences: "Interface-Einstellungen" internal_error: "Hoppla, was passiert ist." interval: "Personalisierte Interval" @@ -1274,6 +1276,7 @@ deu: method: "Verfahren" minimal_temperature: "minimale Temperatur" minimum_amount: "Mindestbetrag" + # minutes: "Min" missing_attributes: "Einige Attribute fehlen" missing_help: "fehlende Seite" # mobile: "Mobile" @@ -1744,6 +1747,7 @@ deu: workers: "Arbeitskräfte" working_duration: "Arbeitsdauer" working_sets_stocks: "Arbeits setzt Aktien" + # working_times: "Working times of %{name}" x_cashes: # one: "%{count} cash" # other: "%{count} cashes" diff --git a/config/locales/deu/enumerize.yml b/config/locales/deu/enumerize.yml index ee67d9ab22..a84ee463d0 100644 --- a/config/locales/deu/enumerize.yml +++ b/config/locales/deu/enumerize.yml @@ -94,6 +94,7 @@ deu: purchase: "Kauf" sale: "Verkauf" # stock: "Stock" + # travel_cost: "Travel" crumb: nature: hard_start: "Harte Start" diff --git a/config/locales/eng/action.yml b/config/locales/eng/action.yml index 015bca1a23..460e737ef4 100644 --- a/config/locales/eng/action.yml +++ b/config/locales/eng/action.yml @@ -948,7 +948,7 @@ eng: accounts: "Accounts" accounts_only_used_at: "Accounts only used at" accounts_to_load: "Accounts to load" - action_duration: "Action duration" #?! + action_duration: "Action duration" activate_entry_autocompletion: "Activate entry autocompletion" active: "Active" #? active_finishing_after: "Active finishing after" #? @@ -1091,7 +1091,7 @@ eng: budgets: "Budgets" #? by_year: "By year" calculate: "Calculate" #? - calculated_hours: "Calculated hours" #?! + calculated_hours: "Calculated hours" calculators: "Calculators" #? calendar: "Calendar" campaign: "Campaign" @@ -1369,6 +1369,7 @@ eng: historic: "Historic" #? home: "Home" # horizontal_timeline: "Horizontal timeline" + hours: "H" #? human_working_duration: "Working duration" #? humans: "HR" iban: "International Bank Account Number (IBAN)" #? @@ -1399,7 +1400,7 @@ eng: input_cost: "Input cost" inputs: "Inputs" inspections: "Inspections" - interactive_maps: "A JS library for interactive maps" + interactive_maps: "A JS library for interactive maps" #?! interface_preferences: "Interface preferences" internal_error: "Oops, something happened." interval: "Personalized Interval" #? @@ -1515,6 +1516,7 @@ eng: method: "Method" #? minimal_temperature: "Minimal temperature" minimum_amount: "Minimum amount" + minutes: "Min" #? missing_attributes: "Some attributes are missing" #?! missing_help: "Missing page" mobile: "Mobile" #? @@ -1955,7 +1957,7 @@ eng: usage: "Usage" #? user_status: "Status" #? users: "Users" - valid: "Valid" #? + valid: "Valid" validate: "Validate" validate_crumbs_for_x_interventions: one: "Validate crumbs for %{count} intervention" @@ -1978,6 +1980,7 @@ eng: workers: "Workers" working_duration: "Working duration" working_sets_stocks: "Working sets stocks" #? + working_times: "Working times of %{name}" #? x_cashes: one: "%{count} cash" other: "%{count} cashes" diff --git a/config/locales/eng/enumerize.yml b/config/locales/eng/enumerize.yml index 3c27c4baff..042c1b61e2 100644 --- a/config/locales/eng/enumerize.yml +++ b/config/locales/eng/enumerize.yml @@ -535,4 +535,4 @@ eng: event: create: "Create" destroy: "Destroy" - update: "Update" + update: "Update" \ No newline at end of file diff --git a/config/locales/eng/models.yml b/config/locales/eng/models.yml index 77731f22c0..e7bc7758c5 100644 --- a/config/locales/eng/models.yml +++ b/config/locales/eng/models.yml @@ -628,6 +628,7 @@ eng: customized_type: "Customized type" daily_nitrogen_production: "Daily nitrogen production" dashboards: "Dashboards" + # data: "Data" dead: "Dead" dead_at: "Dead on" dead_line_at: "Dead line at" diff --git a/config/locales/fra/action.yml b/config/locales/fra/action.yml index a199099d85..9b5b18cc7b 100644 --- a/config/locales/fra/action.yml +++ b/config/locales/fra/action.yml @@ -1386,6 +1386,7 @@ fra: hint: "Astuce\_: %{value}" historic: "Historique" home: "Accueil" + hours: "H" human_target_names: "Nom des cibles" #? human_working_duration: "Temps de travail" human_working_zone_area: "Zone travaillée" #? @@ -1604,6 +1605,7 @@ fra: min_level: "Niveau minimum" #? minimal_temperature: "Température minimale" minimum_amount: "Montant minimum" + minutes: "Min" missing_attributes: "Des champs sont manquants" missing_help: "Page inexistante" mistake_on_quantities_sum: "La somme des quantités n’est pas égale à la quantité totale produite" #? @@ -2311,6 +2313,7 @@ fra: working_area: "Surface travaillée" #? working_duration: "Temps de travail" working_sets_stocks: "Stocks d’ensembles de produits" + working_times: "Temps de travaux de %{name}" working_zone: "Zone travaillée" #? x_cashes: one: "1 compte bancaire" diff --git a/config/locales/fra/enumerize.yml b/config/locales/fra/enumerize.yml index 9f3b4074de..e78ca5da00 100644 --- a/config/locales/fra/enumerize.yml +++ b/config/locales/fra/enumerize.yml @@ -518,4 +518,4 @@ fra: event: create: "Créer" destroy: "Détruire" - update: "Mettre à jour" + update: "Mettre à jour" \ No newline at end of file diff --git a/config/locales/ita/action.yml b/config/locales/ita/action.yml index 4812bc4dfc..f40e326a73 100644 --- a/config/locales/ita/action.yml +++ b/config/locales/ita/action.yml @@ -1193,6 +1193,7 @@ ita: # hint: "Hint: %{value}" historic: "Storico" home: "Casa" + # hours: "H" human_working_duration: "durata di funzionamento" # humans: "HR" # iban: "International Bank Account Number (IBAN)" @@ -1224,6 +1225,7 @@ ita: input_cost_per_hectare: "costo di ingresso per ettaro" #? inputs: "ingressi" inspections: "ispezioni" + # interactive_maps: "A JS library for interactive maps" interface_preferences: "Preferenze di interfaccia" internal_error: "Ops, qualcosa è successo." interval: "Intervallo personalizzato" @@ -1340,6 +1342,7 @@ ita: method: "metodo" minimal_temperature: "temperatura minima" minimum_amount: "Quantità minima" + # minutes: "Min" missing_attributes: "Alcuni attributi mancano" missing_help: "pagina mancante" # mobile: "Mobile" @@ -1810,6 +1813,7 @@ ita: workers: "Lavoratori" working_duration: "durata di funzionamento" working_sets_stocks: "Working set scorte" + # working_times: "Working times of %{name}" x_cashes: # one: "%{count} cash" # other: "%{count} cashes" diff --git a/config/locales/ita/enumerize.yml b/config/locales/ita/enumerize.yml index f30f606a74..2913753f6f 100644 --- a/config/locales/ita/enumerize.yml +++ b/config/locales/ita/enumerize.yml @@ -94,6 +94,7 @@ ita: purchase: "Acquista" sale: "Vendita" stock: "Azione" + # travel_cost: "Travel" crumb: nature: hard_start: "Inizio difficile" diff --git a/config/locales/jpn/action.yml b/config/locales/jpn/action.yml index 1b13408039..5eb6a3137f 100644 --- a/config/locales/jpn/action.yml +++ b/config/locales/jpn/action.yml @@ -1195,6 +1195,7 @@ jpn: # hint: "Hint: %{value}" historic: "歴史的" home: "持て成しの手伝いに帰り" + # hours: "H" human_working_duration: "作業期間" # humans: "HR" iban: "国際銀行口座番号(IBAN)" @@ -1226,6 +1227,7 @@ jpn: input_cost_per_hectare: "ヘクタール当たりの入力コスト" #? inputs: "入力" inspections: "検査" + # interactive_maps: "A JS library for interactive maps" interface_preferences: "インターフェースのプリファレンス" internal_error: "おっと、何かが起こりました。" interval: "パーソナライズされた間隔" @@ -1346,6 +1348,7 @@ jpn: method: "方法" minimal_temperature: "最小限の温度" minimum_amount: "最小量" + # minutes: "Min" missing_attributes: "一部の属性は失われています" missing_help: "無意味なページ" mobile: "モバイル" @@ -1817,6 +1820,7 @@ jpn: workers: "労働者" working_duration: "作業期間" working_sets_stocks: "作業は、株式を設定します" + # working_times: "Working times of %{name}" x_cashes: # one: "%{count} cash" # other: "%{count} cashes" diff --git a/config/locales/jpn/enumerize.yml b/config/locales/jpn/enumerize.yml index a5b8e3ca50..98b1a8637d 100644 --- a/config/locales/jpn/enumerize.yml +++ b/config/locales/jpn/enumerize.yml @@ -94,6 +94,7 @@ jpn: purchase: "購入" sale: "販売" stock: "株式" + # travel_cost: "Travel" crumb: nature: hard_start: "ハードスタート" diff --git a/config/locales/por/action.yml b/config/locales/por/action.yml index 9bbe12ac8d..e5eb9613b4 100644 --- a/config/locales/por/action.yml +++ b/config/locales/por/action.yml @@ -1132,6 +1132,7 @@ por: # hint: "Hint: %{value}" historic: "Histórico" home: "Casa" + # hours: "H" human_working_duration: "Duração de trabalho" # humans: "HR" iban: "Banco Número Internacional de Conta (IBAN)" @@ -1163,6 +1164,7 @@ por: input_cost_per_hectare: "Custo de insumos por hectare" #? inputs: "Entradas" inspections: "inspeções" + # interactive_maps: "A JS library for interactive maps" interface_preferences: "Preferências de interface" internal_error: "Opa, algo aconteceu." interval: "Intervalo personalizado" @@ -1279,6 +1281,7 @@ por: method: "Método" minimal_temperature: "Temperatura mínima" minimum_amount: "Quantidade mínima" + # minutes: "Min" missing_attributes: "Alguns atributos estão faltando" missing_help: "Página perdida" mobile: "Móvel" @@ -1749,6 +1752,7 @@ por: workers: "Trabalhadores" working_duration: "Duração de trabalho" working_sets_stocks: "Trabalho define stocks" + # working_times: "Working times of %{name}" x_cashes: # one: "%{count} cash" # other: "%{count} cashes" diff --git a/config/locales/por/enumerize.yml b/config/locales/por/enumerize.yml index 5144a8256c..68707c4a0b 100644 --- a/config/locales/por/enumerize.yml +++ b/config/locales/por/enumerize.yml @@ -96,6 +96,7 @@ por: purchase: "Compra" sale: "Venda" stock: "Estoque" + # travel_cost: "Travel" crumb: nature: hard_start: "Início difícil" diff --git a/config/locales/spa/action.yml b/config/locales/spa/action.yml index 426bef643f..a8ce74d5a0 100644 --- a/config/locales/spa/action.yml +++ b/config/locales/spa/action.yml @@ -1253,6 +1253,7 @@ spa: # hint: "Hint: %{value}" historic: "Histórico" home: "Vuelta a la cogida de la ayuda" + # hours: "H" human_working_duration: "Duración de trabajo" humans: "HORA" iban: "Numero de cuento bancario internacional (IBAN)" @@ -1286,6 +1287,7 @@ spa: insert_actual_password: "Coja su contraseña actual" #? insert_password: "Coja su nueva contraseña" #? inspections: "inspecciones" + # interactive_maps: "A JS library for interactive maps" interface_preferences: "Preferencias de la interfaz" internal_error: "Vaya, algo sucedió." international_normal_vat_collected: "Tasa normal a 8,5%" #? @@ -1426,6 +1428,7 @@ spa: method: "Método" minimal_temperature: "Temperatura mínima" minimum_amount: "Monto minimo" + # minutes: "Min" missing_attributes: "Algunos atributos faltan" missing_help: "La página no existe" mobile: "Móvil" @@ -1983,6 +1986,7 @@ spa: workers: "Trabajadores" working_duration: "Duración de trabajo" working_sets_stocks: "Trabajo establece las existencias" + # working_times: "Working times of %{name}" x_cashes: # one: "%{count} cash" # other: "%{count} cashes" diff --git a/config/locales/spa/enumerize.yml b/config/locales/spa/enumerize.yml index 657a3e5bbb..f09a4ad8ed 100644 --- a/config/locales/spa/enumerize.yml +++ b/config/locales/spa/enumerize.yml @@ -94,6 +94,7 @@ spa: purchase: "Compra" sale: "Venta" stock: "Valores" + # travel_cost: "Travel" crumb: nature: hard_start: "Inicio difícil," diff --git a/config/rights.yml b/config/rights.yml index 654b2c8df1..d7f00c0fe5 100644 --- a/config/rights.yml +++ b/config/rights.yml @@ -106,6 +106,8 @@ # - "backend/helps#show" # - "backend/helps#toggle" # - "backend/inspections#export" +# - "backend/intervention_participations#create" +# - "backend/intervention_participations#participations_modal" # - "backend/interventions#change_page" # - "backend/januses#toggle" # - "backend/kujakus#toggle" diff --git a/db/tables.yml b/db/tables.yml index 40f85761d0..193baab8b7 100644 --- a/db/tables.yml +++ b/db/tables.yml @@ -110,6 +110,8 @@ accounts: usages: type: text activities: + codes: + type: jsonb created_at: type: datetime required: true @@ -1618,6 +1620,8 @@ crumbs: type: integer references: user cultivable_zones: + codes: + type: jsonb created_at: type: datetime required: true @@ -3278,6 +3282,8 @@ integrations: creator_id: type: integer references: user + data: + type: jsonb id: type: integer required: true @@ -6259,6 +6265,8 @@ products: type: integer references: product_nature_category required: true + codes: + type: jsonb country: type: string created_at: diff --git a/test/fixtures/activities.yml b/test/fixtures/activities.yml index 3c20ba0f3a..e3688a319b 100644 --- a/test/fixtures/activities.yml +++ b/test/fixtures/activities.yml @@ -22,6 +22,7 @@ # # == Table: activities # +# codes :jsonb # created_at :datetime not null # creator_id :integer # cultivation_variety :string diff --git a/test/fixtures/cultivable_zones.yml b/test/fixtures/cultivable_zones.yml index a82048bc1c..6a83440124 100644 --- a/test/fixtures/cultivable_zones.yml +++ b/test/fixtures/cultivable_zones.yml @@ -22,6 +22,7 @@ # # == Table: cultivable_zones # +# codes :jsonb # created_at :datetime not null # creator_id :integer # custom_fields :jsonb diff --git a/test/fixtures/integrations.yml b/test/fixtures/integrations.yml index baa94f0265..ba2ab70ca6 100644 --- a/test/fixtures/integrations.yml +++ b/test/fixtures/integrations.yml @@ -25,6 +25,7 @@ # ciphered_parameters :jsonb # created_at :datetime not null # creator_id :integer +# data :jsonb # id :integer not null, primary key # initialization_vectors :jsonb # lock_version :integer default(0), not null diff --git a/test/fixtures/products.yml b/test/fixtures/products.yml index 1da0b4f0ca..a2c40fa16c 100644 --- a/test/fixtures/products.yml +++ b/test/fixtures/products.yml @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/activity_test.rb b/test/models/activity_test.rb index 79911bd39c..c2cb8da565 100644 --- a/test/models/activity_test.rb +++ b/test/models/activity_test.rb @@ -22,6 +22,7 @@ # # == Table: activities # +# codes :jsonb # created_at :datetime not null # creator_id :integer # cultivation_variety :string diff --git a/test/models/animal_group_test.rb b/test/models/animal_group_test.rb index 6295347905..7f6ae4dac3 100644 --- a/test/models/animal_group_test.rb +++ b/test/models/animal_group_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/animal_test.rb b/test/models/animal_test.rb index 0e715b6631..360815cde5 100644 --- a/test/models/animal_test.rb +++ b/test/models/animal_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/bioproduct_test.rb b/test/models/bioproduct_test.rb index 95521f0180..1a81394319 100644 --- a/test/models/bioproduct_test.rb +++ b/test/models/bioproduct_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/building_division_test.rb b/test/models/building_division_test.rb index 300188d1b2..c333b3b806 100644 --- a/test/models/building_division_test.rb +++ b/test/models/building_division_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/building_test.rb b/test/models/building_test.rb index b31781322e..b86912db1c 100644 --- a/test/models/building_test.rb +++ b/test/models/building_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/cultivable_zone_test.rb b/test/models/cultivable_zone_test.rb index 9a9cf3720b..bde1d97a06 100644 --- a/test/models/cultivable_zone_test.rb +++ b/test/models/cultivable_zone_test.rb @@ -22,6 +22,7 @@ # # == Table: cultivable_zones # +# codes :jsonb # created_at :datetime not null # creator_id :integer # custom_fields :jsonb diff --git a/test/models/easement_test.rb b/test/models/easement_test.rb index ddeeb1bdfa..7d376c18ec 100644 --- a/test/models/easement_test.rb +++ b/test/models/easement_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/equipment_fleet_test.rb b/test/models/equipment_fleet_test.rb index 644029e122..2656991345 100644 --- a/test/models/equipment_fleet_test.rb +++ b/test/models/equipment_fleet_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/equipment_test.rb b/test/models/equipment_test.rb index cce6323b9d..a11010d8f2 100644 --- a/test/models/equipment_test.rb +++ b/test/models/equipment_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/fungus_test.rb b/test/models/fungus_test.rb index 199270692a..d064b3a1eb 100644 --- a/test/models/fungus_test.rb +++ b/test/models/fungus_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/integration_test.rb b/test/models/integration_test.rb index 7c562ef35d..a2300cf403 100644 --- a/test/models/integration_test.rb +++ b/test/models/integration_test.rb @@ -25,6 +25,7 @@ # ciphered_parameters :jsonb # created_at :datetime not null # creator_id :integer +# data :jsonb # id :integer not null, primary key # initialization_vectors :jsonb # lock_version :integer default(0), not null diff --git a/test/models/land_parcel_test.rb b/test/models/land_parcel_test.rb index 9f446cf979..7e04c316f1 100644 --- a/test/models/land_parcel_test.rb +++ b/test/models/land_parcel_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/matter_test.rb b/test/models/matter_test.rb index db7c8f7a25..76e85d8b74 100644 --- a/test/models/matter_test.rb +++ b/test/models/matter_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/plant_test.rb b/test/models/plant_test.rb index 6baeddb950..44ef3b6091 100644 --- a/test/models/plant_test.rb +++ b/test/models/plant_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/product_group_test.rb b/test/models/product_group_test.rb index 530fe785dd..58880783f5 100644 --- a/test/models/product_group_test.rb +++ b/test/models/product_group_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/product_test.rb b/test/models/product_test.rb index e4169285fb..901cea05b3 100644 --- a/test/models/product_test.rb +++ b/test/models/product_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/settlement_test.rb b/test/models/settlement_test.rb index 047b4d4f55..443f7be6f8 100644 --- a/test/models/settlement_test.rb +++ b/test/models/settlement_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/sub_zone_test.rb b/test/models/sub_zone_test.rb index 744b0e5e59..3df231162d 100644 --- a/test/models/sub_zone_test.rb +++ b/test/models/sub_zone_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/worker_test.rb b/test/models/worker_test.rb index 7c244a4099..3620dc819a 100644 --- a/test/models/worker_test.rb +++ b/test/models/worker_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer diff --git a/test/models/zone_test.rb b/test/models/zone_test.rb index 445d0d6948..c551b585e1 100644 --- a/test/models/zone_test.rb +++ b/test/models/zone_test.rb @@ -27,6 +27,7 @@ # birth_farm_number :string # born_at :datetime # category_id :integer not null +# codes :jsonb # country :string # created_at :datetime not null # creator_id :integer From 5ff8b0a75c1b1b50d8821d2f8f67198b2c2f9bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 13 Jul 2017 15:55:36 +0200 Subject: [PATCH 10/38] Change product parameters order --- config/procedures/all_in_one_sowing.xml | 4 ++-- config/procedures/animal_group_changing.xml | 4 ++-- config/procedures/animal_housing_cleaning.xml | 4 ++-- config/procedures/animal_housing_disinfection.xml | 4 ++-- config/procedures/animal_housing_mulching.xml | 4 ++-- config/procedures/chemical_mechanical_weeding.xml | 2 +- config/procedures/crop_residues_grinding.xml | 2 +- config/procedures/cutting.xml | 2 +- config/procedures/detasseling.xml | 2 +- config/procedures/direct_silage.xml | 2 +- config/procedures/fertilizing.xml | 2 +- config/procedures/gas_weeding.xml | 4 ++-- config/procedures/ground_destratification.xml | 2 +- config/procedures/hand_weeding.xml | 2 +- config/procedures/harvesting.xml | 4 ++-- config/procedures/herd_feeding.xml | 4 ++-- config/procedures/hilling.xml | 2 +- config/procedures/hilling_for_sifting.xml | 2 +- config/procedures/hoeing.xml | 2 +- config/procedures/indirect_silage.xml | 2 +- config/procedures/installation_maintenance.xml | 4 ++-- config/procedures/inter_row_hoeing.xml | 2 +- config/procedures/land_parcel_grinding.xml | 2 +- config/procedures/lifting.xml | 2 +- config/procedures/mechanical_planting.xml | 4 ++-- config/procedures/milking.xml | 2 +- config/procedures/net_installation.xml | 4 ++-- config/procedures/net_removing.xml | 4 ++-- config/procedures/plant_cover_sowing.xml | 4 ++-- config/procedures/plant_covering.xml | 2 +- config/procedures/plant_mowing.xml | 2 +- config/procedures/plant_mulching.xml | 2 +- config/procedures/plant_uncovering.xml | 2 +- config/procedures/plant_watering.xml | 2 +- config/procedures/plant_watering_installation.xml | 2 +- config/procedures/plantation_unfixing.xml | 2 +- config/procedures/plowing.xml | 2 +- config/procedures/pollination.xml | 4 ++-- config/procedures/raking.xml | 2 +- config/procedures/seedbed_preparing.xml | 2 +- config/procedures/seedling_sorting.xml | 2 +- config/procedures/sifting.xml | 2 +- config/procedures/sowing.xml | 4 ++-- config/procedures/sowing_with_spraying.xml | 4 ++-- config/procedures/spraying.xml | 2 +- config/procedures/steam_weeding.xml | 2 +- config/procedures/straw_bunching.xml | 2 +- config/procedures/superficial_plowing.xml | 2 +- config/procedures/swathing.xml | 2 +- config/procedures/topkilling.xml | 2 +- config/procedures/transportation.xml | 2 +- config/procedures/trellising.xml | 2 +- config/procedures/tunnel_installation.xml | 4 ++-- config/procedures/tunnel_removing.xml | 4 ++-- config/procedures/uncompacting.xml | 2 +- 55 files changed, 73 insertions(+), 73 deletions(-) diff --git a/config/procedures/all_in_one_sowing.xml b/config/procedures/all_in_one_sowing.xml index ca2dacdaeb..79fcec556d 100644 --- a/config/procedures/all_in_one_sowing.xml +++ b/config/procedures/all_in_one_sowing.xml @@ -70,10 +70,10 @@ backward="(POPULATION * PRODUCT..net_mass(kilogram) * (PRODUCT.nitrogen_concentration(percent) / 100)) / sum_working_zone_areas(land_parcel, :hectare)" forward="(VALUE * sum_working_zone_areas(land_parcel, :hectare)) / (PRODUCT..net_mass(kilogram) * PRODUCT.nitrogen_concentration(percent) / 100)"/> - - + + diff --git a/config/procedures/animal_group_changing.xml b/config/procedures/animal_group_changing.xml index 7485bd1a80..6f0f9c8473 100644 --- a/config/procedures/animal_group_changing.xml +++ b/config/procedures/animal_group_changing.xml @@ -7,10 +7,10 @@ - - + + diff --git a/config/procedures/animal_housing_cleaning.xml b/config/procedures/animal_housing_cleaning.xml index b16af8de81..bf1438b77f 100644 --- a/config/procedures/animal_housing_cleaning.xml +++ b/config/procedures/animal_housing_cleaning.xml @@ -25,10 +25,10 @@ backward="POPULATION * PRODUCT..net_volume(liter)" forward="VALUE / PRODUCT..net_volume(liter)"/> - - + + \ No newline at end of file diff --git a/config/procedures/animal_housing_disinfection.xml b/config/procedures/animal_housing_disinfection.xml index 95d293d03a..ad4c5c4d69 100644 --- a/config/procedures/animal_housing_disinfection.xml +++ b/config/procedures/animal_housing_disinfection.xml @@ -19,10 +19,10 @@ backward="POPULATION * PRODUCT..net_volume(liter)" forward="VALUE / PRODUCT..net_volume(liter)"/> - - + + \ No newline at end of file diff --git a/config/procedures/animal_housing_mulching.xml b/config/procedures/animal_housing_mulching.xml index 312381f702..f324ce7324 100644 --- a/config/procedures/animal_housing_mulching.xml +++ b/config/procedures/animal_housing_mulching.xml @@ -19,10 +19,10 @@ backward="POPULATION * PRODUCT..net_volume(liter)" forward="VALUE / PRODUCT..net_volume(liter)"/> - - + + \ No newline at end of file diff --git a/config/procedures/chemical_mechanical_weeding.xml b/config/procedures/chemical_mechanical_weeding.xml index 5899ece627..7a1d28e4ca 100644 --- a/config/procedures/chemical_mechanical_weeding.xml +++ b/config/procedures/chemical_mechanical_weeding.xml @@ -21,10 +21,10 @@ backward="(POPULATION * PRODUCT..net_volume(liter)) / sum_working_zone_areas(cultivation, :hectare)" forward="(VALUE * sum_working_zone_areas(cultivation, :hectare)) / PRODUCT..net_volume(liter)"/> + - \ No newline at end of file diff --git a/config/procedures/crop_residues_grinding.xml b/config/procedures/crop_residues_grinding.xml index dcb0592025..d7a8d4968d 100644 --- a/config/procedures/crop_residues_grinding.xml +++ b/config/procedures/crop_residues_grinding.xml @@ -6,9 +6,9 @@ + - \ No newline at end of file diff --git a/config/procedures/cutting.xml b/config/procedures/cutting.xml index 54c77342f7..8cc72f4441 100644 --- a/config/procedures/cutting.xml +++ b/config/procedures/cutting.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/detasseling.xml b/config/procedures/detasseling.xml index 2af09d0097..d6701e5fd5 100644 --- a/config/procedures/detasseling.xml +++ b/config/procedures/detasseling.xml @@ -5,9 +5,9 @@ - + \ No newline at end of file diff --git a/config/procedures/direct_silage.xml b/config/procedures/direct_silage.xml index bea5f89e86..509a6074de 100644 --- a/config/procedures/direct_silage.xml +++ b/config/procedures/direct_silage.xml @@ -21,9 +21,9 @@ backward="(POPULATION * VARIANT.net_mass(ton)) / sum_working_zone_areas(cultivation, :hectare)" forward="(VALUE * sum_working_zone_areas(cultivation, :hectare)) / VARIANT.net_mass(ton)"/> + - diff --git a/config/procedures/fertilizing.xml b/config/procedures/fertilizing.xml index 74633a1e64..2d9ee5bfb5 100644 --- a/config/procedures/fertilizing.xml +++ b/config/procedures/fertilizing.xml @@ -24,10 +24,10 @@ backward="(POPULATION * PRODUCT..net_mass(kilogram) * (PRODUCT.nitrogen_concentration(percent) / 100)) / sum_working_zone_areas(cultivation, :hectare)" forward="(VALUE * sum_working_zone_areas(cultivation, :hectare)) / (PRODUCT..net_mass(kilogram) * PRODUCT.nitrogen_concentration(percent) / 100)"/> + - \ No newline at end of file diff --git a/config/procedures/gas_weeding.xml b/config/procedures/gas_weeding.xml index db0aa05666..d44b17a5d5 100644 --- a/config/procedures/gas_weeding.xml +++ b/config/procedures/gas_weeding.xml @@ -9,10 +9,10 @@ - - + + \ No newline at end of file diff --git a/config/procedures/ground_destratification.xml b/config/procedures/ground_destratification.xml index 4fd0c046d9..9b2eca5639 100644 --- a/config/procedures/ground_destratification.xml +++ b/config/procedures/ground_destratification.xml @@ -5,8 +5,8 @@ - + \ No newline at end of file diff --git a/config/procedures/hand_weeding.xml b/config/procedures/hand_weeding.xml index ffd5a2249d..3269904ba5 100644 --- a/config/procedures/hand_weeding.xml +++ b/config/procedures/hand_weeding.xml @@ -9,8 +9,8 @@ - + \ No newline at end of file diff --git a/config/procedures/harvesting.xml b/config/procedures/harvesting.xml index b047149db1..e1a343ee48 100644 --- a/config/procedures/harvesting.xml +++ b/config/procedures/harvesting.xml @@ -26,11 +26,11 @@ backward="(POPULATION * VARIANT.net_mass(quintal)) / sum_working_zone_areas(plant, :hectare)" forward="(VALUE * sum_working_zone_areas(plant, :hectare)) / VARIANT.net_mass(quintal)"/> + + - - \ No newline at end of file diff --git a/config/procedures/herd_feeding.xml b/config/procedures/herd_feeding.xml index f642db2825..01ef4abf7d 100644 --- a/config/procedures/herd_feeding.xml +++ b/config/procedures/herd_feeding.xml @@ -26,10 +26,10 @@ backward="POPULATION * (PRODUCT..net_mass(ton) * PRODUCT.dry_matter_rate(mass_percent) / 100)" forward="VALUE / ( PRODUCT..net_mass(ton) * PRODUCT.dry_matter_rate(mass_percent) / 100)"/> - - + + diff --git a/config/procedures/hilling.xml b/config/procedures/hilling.xml index e8528c56de..4f42be995b 100644 --- a/config/procedures/hilling.xml +++ b/config/procedures/hilling.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/hilling_for_sifting.xml b/config/procedures/hilling_for_sifting.xml index 010a8b094d..51c384ed60 100644 --- a/config/procedures/hilling_for_sifting.xml +++ b/config/procedures/hilling_for_sifting.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/hoeing.xml b/config/procedures/hoeing.xml index 1e957b275b..0584b34e66 100644 --- a/config/procedures/hoeing.xml +++ b/config/procedures/hoeing.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/indirect_silage.xml b/config/procedures/indirect_silage.xml index 45513b213e..a2e4b8c96c 100644 --- a/config/procedures/indirect_silage.xml +++ b/config/procedures/indirect_silage.xml @@ -28,8 +28,8 @@ backward="(POPULATION * VARIANT.net_mass(ton)) / sum_working_zone_areas(cultivation, :hectare)" forward="(VALUE * sum_working_zone_areas(cultivation, :hectare)) / VARIANT.net_mass(ton)"/> - + diff --git a/config/procedures/installation_maintenance.xml b/config/procedures/installation_maintenance.xml index d42dea0c34..d16a578a7a 100644 --- a/config/procedures/installation_maintenance.xml +++ b/config/procedures/installation_maintenance.xml @@ -8,10 +8,10 @@ - - + + \ No newline at end of file diff --git a/config/procedures/inter_row_hoeing.xml b/config/procedures/inter_row_hoeing.xml index 873dcf590d..cee6207e74 100644 --- a/config/procedures/inter_row_hoeing.xml +++ b/config/procedures/inter_row_hoeing.xml @@ -5,9 +5,9 @@ + - diff --git a/config/procedures/land_parcel_grinding.xml b/config/procedures/land_parcel_grinding.xml index 4bb28c663d..6f52ec9ec1 100644 --- a/config/procedures/land_parcel_grinding.xml +++ b/config/procedures/land_parcel_grinding.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/lifting.xml b/config/procedures/lifting.xml index 57fbd14026..4e81458e9b 100644 --- a/config/procedures/lifting.xml +++ b/config/procedures/lifting.xml @@ -6,9 +6,9 @@ + - \ No newline at end of file diff --git a/config/procedures/mechanical_planting.xml b/config/procedures/mechanical_planting.xml index 11ba7d4b7c..86cc2de91b 100644 --- a/config/procedures/mechanical_planting.xml +++ b/config/procedures/mechanical_planting.xml @@ -36,10 +36,10 @@ backward="POPULATION * PRODUCT..items_count / 1000" forward="VALUE * 1000 / PRODUCT..items_count"/> - - + + \ No newline at end of file diff --git a/config/procedures/milking.xml b/config/procedures/milking.xml index 931851956b..f34b758957 100644 --- a/config/procedures/milking.xml +++ b/config/procedures/milking.xml @@ -16,8 +16,8 @@ backward="POPULATION * VARIANT.net_mass(kilogram)" forward="VALUE / VARIANT.net_mass(kilogram)"/> - + \ No newline at end of file diff --git a/config/procedures/net_installation.xml b/config/procedures/net_installation.xml index 716d44af03..c6df3309bc 100644 --- a/config/procedures/net_installation.xml +++ b/config/procedures/net_installation.xml @@ -16,10 +16,10 @@ backward="POPULATION * (PRODUCT..length(meter) * PRODUCT..width(meter))" forward="VALUE / (PRODUCT..length(meter) * PRODUCT..width(meter))"/> - - + + \ No newline at end of file diff --git a/config/procedures/net_removing.xml b/config/procedures/net_removing.xml index 91a260b838..3ed1808bb1 100644 --- a/config/procedures/net_removing.xml +++ b/config/procedures/net_removing.xml @@ -8,10 +8,10 @@ - - + + \ No newline at end of file diff --git a/config/procedures/plant_cover_sowing.xml b/config/procedures/plant_cover_sowing.xml index c2443fcff2..0061147a60 100644 --- a/config/procedures/plant_cover_sowing.xml +++ b/config/procedures/plant_cover_sowing.xml @@ -28,10 +28,10 @@ backward="(POPULATION * PRODUCT..net_mass(gram)) / PRODUCT..thousand_grains_mass(gram)" forward="(VALUE * PRODUCT..thousand_grains_mass(gram)) / PRODUCT..net_mass(gram)"/> - - + + \ No newline at end of file diff --git a/config/procedures/plant_covering.xml b/config/procedures/plant_covering.xml index d139d7c7c1..8207429cdd 100644 --- a/config/procedures/plant_covering.xml +++ b/config/procedures/plant_covering.xml @@ -16,9 +16,9 @@ backward="POPULATION * (PRODUCT..length(meter) * PRODUCT..width(meter))" forward="VALUE / (PRODUCT..length(meter) * PRODUCT..width(meter))"/> + - diff --git a/config/procedures/plant_mowing.xml b/config/procedures/plant_mowing.xml index a774cc2312..4727462caf 100644 --- a/config/procedures/plant_mowing.xml +++ b/config/procedures/plant_mowing.xml @@ -19,9 +19,9 @@ backward="(POPULATION * VARIANT.net_mass(ton)) / sum(plant, :net_surface_area, :hectare)" forward="(VALUE * sum(plant, :net_surface_area, :hectare)) / VARIANT.net_mass(ton)"/> + - diff --git a/config/procedures/plant_mulching.xml b/config/procedures/plant_mulching.xml index 12074b209d..df746f53a6 100644 --- a/config/procedures/plant_mulching.xml +++ b/config/procedures/plant_mulching.xml @@ -16,9 +16,9 @@ backward="(POPULATION * PRODUCT.net_length(meter) * PRODUCT.width(meter)) / sum(cultivation, :net_surface_area, :square_meter)" forward="(VALUE * sum(cultivation, :net_surface_area, :square_meter)) / (PRODUCT.net_length(meter) * PRODUCT.width(meter))"/> + - \ No newline at end of file diff --git a/config/procedures/plant_uncovering.xml b/config/procedures/plant_uncovering.xml index 8164fab19b..b78678a91e 100644 --- a/config/procedures/plant_uncovering.xml +++ b/config/procedures/plant_uncovering.xml @@ -8,9 +8,9 @@ + - \ No newline at end of file diff --git a/config/procedures/plant_watering.xml b/config/procedures/plant_watering.xml index 07ab657831..d0fea73c6e 100644 --- a/config/procedures/plant_watering.xml +++ b/config/procedures/plant_watering.xml @@ -39,8 +39,8 @@ backward="(POPULATION * PRODUCT..net_mass(kilogram) * (PRODUCT.nitrogen_concentration(percent) / 100)) / sum_working_zone_areas(cultivation, :hectare)" forward="(VALUE * sum_working_zone_areas(cultivation, :hectare)) / (PRODUCT..net_mass(kilogram) * PRODUCT.nitrogen_concentration(percent) / 100)"/> - + \ No newline at end of file diff --git a/config/procedures/plant_watering_installation.xml b/config/procedures/plant_watering_installation.xml index a849443a28..f14a3e626c 100644 --- a/config/procedures/plant_watering_installation.xml +++ b/config/procedures/plant_watering_installation.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/plantation_unfixing.xml b/config/procedures/plantation_unfixing.xml index 9237bbe26f..31c40e4357 100644 --- a/config/procedures/plantation_unfixing.xml +++ b/config/procedures/plantation_unfixing.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/plowing.xml b/config/procedures/plowing.xml index 83834af789..b5888d04b3 100644 --- a/config/procedures/plowing.xml +++ b/config/procedures/plowing.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/pollination.xml b/config/procedures/pollination.xml index a59643167f..052160cae5 100644 --- a/config/procedures/pollination.xml +++ b/config/procedures/pollination.xml @@ -8,12 +8,12 @@ + + - - \ No newline at end of file diff --git a/config/procedures/raking.xml b/config/procedures/raking.xml index f651ab0935..d7cff88022 100644 --- a/config/procedures/raking.xml +++ b/config/procedures/raking.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/seedbed_preparing.xml b/config/procedures/seedbed_preparing.xml index d821bfd72e..87ba0a5161 100644 --- a/config/procedures/seedbed_preparing.xml +++ b/config/procedures/seedbed_preparing.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/seedling_sorting.xml b/config/procedures/seedling_sorting.xml index ab5df63d95..39154fbeb4 100644 --- a/config/procedures/seedling_sorting.xml +++ b/config/procedures/seedling_sorting.xml @@ -9,8 +9,8 @@ - + \ No newline at end of file diff --git a/config/procedures/sifting.xml b/config/procedures/sifting.xml index c77757cd37..7519f8f1bf 100644 --- a/config/procedures/sifting.xml +++ b/config/procedures/sifting.xml @@ -5,10 +5,10 @@ + - \ No newline at end of file diff --git a/config/procedures/sowing.xml b/config/procedures/sowing.xml index f1450b83f3..fc01dda7b6 100644 --- a/config/procedures/sowing.xml +++ b/config/procedures/sowing.xml @@ -36,10 +36,10 @@ backward="(POPULATION * PRODUCT..net_mass(gram)) / PRODUCT..thousand_grains_mass(gram)" forward="(VALUE * PRODUCT..thousand_grains_mass(gram)) / PRODUCT..net_mass(gram)"/> - - + + diff --git a/config/procedures/sowing_with_spraying.xml b/config/procedures/sowing_with_spraying.xml index 1a00420297..c987cc7ebb 100644 --- a/config/procedures/sowing_with_spraying.xml +++ b/config/procedures/sowing_with_spraying.xml @@ -51,10 +51,10 @@ backward="(POPULATION * PRODUCT..net_volume(liter)) / sum_working_zone_areas(land_parcel, :hectare)" forward="(VALUE * sum_working_zone_areas(land_parcel, :hectare)) / PRODUCT..net_volume(liter)"/> - - + + diff --git a/config/procedures/spraying.xml b/config/procedures/spraying.xml index 24e14eddd1..8b77619c17 100644 --- a/config/procedures/spraying.xml +++ b/config/procedures/spraying.xml @@ -21,9 +21,9 @@ backward="(POPULATION * PRODUCT..net_volume(liter)) / sum_working_zone_areas(cultivation, :hectare)" forward="(VALUE * sum_working_zone_areas(cultivation, :hectare)) / PRODUCT..net_volume(liter)"/> + - \ No newline at end of file diff --git a/config/procedures/steam_weeding.xml b/config/procedures/steam_weeding.xml index 47f2d4d7fd..59ae523655 100644 --- a/config/procedures/steam_weeding.xml +++ b/config/procedures/steam_weeding.xml @@ -13,8 +13,8 @@ backward="POPULATION * PRODUCT..net_volume(liter)" forward="VALUE / PRODUCT..net_volume(liter)"/> - + \ No newline at end of file diff --git a/config/procedures/straw_bunching.xml b/config/procedures/straw_bunching.xml index 4689e12ef7..fa4dee0dd5 100644 --- a/config/procedures/straw_bunching.xml +++ b/config/procedures/straw_bunching.xml @@ -26,9 +26,9 @@ backward="(POPULATION * VARIANT.net_mass(ton)) / sum(cultivation, :net_surface_area, :hectare)" forward="(VALUE * sum(cultivation, :net_surface_area, :hectare)) / VARIANT.net_mass(ton)"/> + - \ No newline at end of file diff --git a/config/procedures/superficial_plowing.xml b/config/procedures/superficial_plowing.xml index 4b9e22488f..835986670a 100644 --- a/config/procedures/superficial_plowing.xml +++ b/config/procedures/superficial_plowing.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/swathing.xml b/config/procedures/swathing.xml index f5f1acef02..a9c3f4bf4b 100644 --- a/config/procedures/swathing.xml +++ b/config/procedures/swathing.xml @@ -6,9 +6,9 @@ + - \ No newline at end of file diff --git a/config/procedures/topkilling.xml b/config/procedures/topkilling.xml index 9b52ffe72f..024296d010 100644 --- a/config/procedures/topkilling.xml +++ b/config/procedures/topkilling.xml @@ -6,9 +6,9 @@ + - \ No newline at end of file diff --git a/config/procedures/transportation.xml b/config/procedures/transportation.xml index aeb95fd04f..577e75d35c 100644 --- a/config/procedures/transportation.xml +++ b/config/procedures/transportation.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file diff --git a/config/procedures/trellising.xml b/config/procedures/trellising.xml index 464676023c..1b233aa9f0 100644 --- a/config/procedures/trellising.xml +++ b/config/procedures/trellising.xml @@ -17,8 +17,8 @@ backward="(POPULATION * PRODUCT..length(meter))" forward="(VALUE / PRODUCT..length(meter))"/> - + diff --git a/config/procedures/tunnel_installation.xml b/config/procedures/tunnel_installation.xml index 16f6e95bfa..3ab60028d0 100644 --- a/config/procedures/tunnel_installation.xml +++ b/config/procedures/tunnel_installation.xml @@ -8,10 +8,10 @@ - - + + \ No newline at end of file diff --git a/config/procedures/tunnel_removing.xml b/config/procedures/tunnel_removing.xml index 25183ac8ac..590f5eed37 100644 --- a/config/procedures/tunnel_removing.xml +++ b/config/procedures/tunnel_removing.xml @@ -8,10 +8,10 @@ - - + + \ No newline at end of file diff --git a/config/procedures/uncompacting.xml b/config/procedures/uncompacting.xml index 1c02224d1a..0b990f0bf1 100644 --- a/config/procedures/uncompacting.xml +++ b/config/procedures/uncompacting.xml @@ -5,9 +5,9 @@ + - \ No newline at end of file From 596c33492845637d32958bbbe55b46f83d1a5f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 20 Jul 2017 12:03:48 +0200 Subject: [PATCH 11/38] Working on auto mode --- Gemfile.lock | 7 +++- .../intervention_participations.js.coffee | 5 +++ .../backend/interventions.js.coffee | 27 ++++++++++++- .../intervention_participations_controller.rb | 27 ++++++++++--- app/models/concerns/indicateable.rb | 40 +++++++++---------- app/models/intervention.rb | 9 +++-- app/models/intervention_participation.rb | 2 +- app/models/journal_entry.rb | 6 +-- .../intervention_participations.scss | 5 +++ .../_participations_modal.html.haml | 15 ++++++- .../_product_parameter.html.haml | 2 +- .../_product_parameter_fields.html.haml | 2 +- config/locales/arb/action.yml | 2 +- config/locales/cmn/action.yml | 2 +- config/locales/deu/action.yml | 2 +- config/locales/fra/action.yml | 2 +- config/locales/fra/aggregators.yml | 16 ++++---- config/locales/ita/action.yml | 2 +- config/locales/jpn/action.yml | 2 +- config/locales/por/action.yml | 2 +- config/locales/spa/action.yml | 2 +- db/structure.sql | 2 +- 22 files changed, 123 insertions(+), 58 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2b4037628d..2c14afeeb6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,7 +65,7 @@ GEM sidekiq (>= 2.11) arel (6.0.4) ast (2.3.0) - autoprefixer-rails (7.1.2.2) + autoprefixer-rails (7.1.2.3) execjs awesome_nested_set (3.1.3) activerecord (>= 4.0.0, < 5.2) @@ -462,7 +462,7 @@ GEM activemodel (>= 3.0.0) builder iban-tools - sexp_processor (4.9.0) + sexp_processor (4.10.0) shoulda-context (1.2.2) sidekiq (4.2.10) concurrent-ruby (~> 1.0) @@ -519,6 +519,9 @@ GEM thor (0.19.4) thread_safe (0.3.6) tilt (2.0.7) + time_diff (0.3.0) + activesupport + i18n timecop (0.9.1) timeliness (0.3.8) tins (1.15.0) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index 326e873e8f..de324b99c8 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -119,6 +119,11 @@ E.interventionParticipations.changeWorkingPeriod(element) + $(document).on "click", '#participation_auto_calculate_equipments', (event) -> + + isChecked = $(event.target).is(':checked') + $('input[name="auto-calcul-mode"]').val(isChecked) + E.interventionParticipations = changeWorkingPeriod: (element) -> diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index 3b5656b6c5..086f0d6601 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -192,17 +192,40 @@ showInterventionParticipationsModal: -> $(document).on 'click', '.has-intervention-participations', (event) -> + targetted_element = $(event.target) intervention_id = $('input[name="intervention_id"]').val() product_id = $(event.target).closest('.nested-product-parameter').find(".selector .selector-value").val() existingParticipation = $('.intervention-participation[data-product-id="' + product_id + '"]').val() + participations = $('intervention_participation') interventionStartedAt = null if intervention_id == "" interventionStartedAt = $('.intervention-started-at').val() + displayCalculMode = false + if $(targetted_element).closest('.nested-driver, .nested-doer').length > 0 && $('input[name="display-calcul-mode"]').length == 0 + $('.simple_form').append('') + displayCalculMode = true + + autoCalculMode = true + if $('input[name="auto-calcul-mode"]').length == 0 + $('.simple_form').append('') + else + autoCalculMode = $('input[name="auto-calcul-mode"]').val() + + + datas = {} + datas['intervention_id'] = intervention_id + datas['product_id'] = product_id + datas['existing_participation'] = existingParticipation + datas['participations'] = participations + datas['intervention_started_at'] = interventionStartedAt + datas['display_calcul_mode'] = displayCalculMode + datas['auto_calcul_mode'] = autoCalculMode + $.ajax url: "/backend/intervention_participations/participations_modal", - data: { intervention_id: intervention_id, product_id: product_id, existing_participation: existingParticipation, intervention_started_at: interventionStartedAt } + data: datas success: (data, status, request) -> @workingTimesModal = new ekylibre.modal('#working_times') @@ -279,7 +302,7 @@ E.interventions.updateAvailabilityInstant($(this).val()) - $(document).on "selector:change", 'input[data-selector-id="intervention_doer_product_id"]', (event) -> + $(document).on "selector:change", 'input[data-selector-id="intervention_doer_product_id"], input[data-selector-id="intervention_tool_product_id"]', (event) -> element = $(event.target) blockElement = element.closest('.nested-fields') diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index d99801be68..3b51b462a3 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -50,7 +50,7 @@ def convert def participations_modal participation = nil - if params["existing_participation"].present? + if params['existing_participation'].present? json_participation = JSON.parse(params['existing_participation']) participation = InterventionParticipation.new(json_participation) else @@ -60,13 +60,28 @@ def participations_modal ) end - if participation.intervention.nil? - intervention_started_at = Time.parse(params["intervention_started_at"]) - else - intervention_started_at = participation.intervention.started_at + intervention_started_at = if participation.intervention.nil? + Time.parse(params['intervention_started_at']) + else + participation.intervention.started_at + end + + intervention_tool = nil + if Product.find(params[:product_id]).is_a?(Equipment) + intervention_tool = participation.intervention.tools.find_by(product_id: params[:product_id]) end - render partial: 'backend/intervention_participations/participations_modal', locals: { participation: participation, intervention_started_at: intervention_started_at } + display_calcul_mode = params[:display_calcul_mode] + auto_calcul_mode = params[:auto_calcul_mode] + + render partial: 'backend/intervention_participations/participations_modal', + locals: { + participation: participation, + intervention_started_at: intervention_started_at, + intervention_tool: intervention_tool, + display_calcul_mode: display_calcul_mode, + auto_calcul_mode: auto_calcul_mode + } end private diff --git a/app/models/concerns/indicateable.rb b/app/models/concerns/indicateable.rb index c39fe99027..17f896cb91 100644 --- a/app/models/concerns/indicateable.rb +++ b/app/models/concerns/indicateable.rb @@ -259,24 +259,24 @@ def operate_on_readings(indicator, value, options = {}) data.update_all(["VALUE = #{expr}".gsub('VALUE', "#{indicator.datatype}_value"), value]) end - DEPRECATED =[ - ["Entry date", "entry_date"], - ["Entry reason", "entry_reason"], - ["Exit reason", "exit_reason"], - ["Father race code", "father_race_code"], - ["Birth date", "birth_date"], - ["End of life witness", "end_of_life_witness"], - ["Entry reason", "entry_reason"], - ["Father country code", "father_country_code"], - ["First calving date", "first_calving_date"], - ["Birth farm number", "birth_farm_number"], - ["Country code", "country_code"], - ["Exit date", "exit_date"], - ["Father identification number", "father_identification_number"], - ["Mother country code", "mother_country_code"], - ["Mother identification number", "mother_identification_number"], - ["Mother race code", "mother_race_code"], - ["Origin country code", "origin_country_code"], - ["Origin identification number", "origin_identification_number"] - ] + DEPRECATED = [ + ['Entry date', 'entry_date'], + ['Entry reason', 'entry_reason'], + ['Exit reason', 'exit_reason'], + ['Father race code', 'father_race_code'], + ['Birth date', 'birth_date'], + ['End of life witness', 'end_of_life_witness'], + ['Entry reason', 'entry_reason'], + ['Father country code', 'father_country_code'], + ['First calving date', 'first_calving_date'], + ['Birth farm number', 'birth_farm_number'], + ['Country code', 'country_code'], + ['Exit date', 'exit_date'], + ['Father identification number', 'father_identification_number'], + ['Mother country code', 'mother_country_code'], + ['Mother identification number', 'mother_identification_number'], + ['Mother race code', 'mother_race_code'], + ['Origin country code', 'origin_country_code'], + ['Origin identification number', 'origin_identification_number'] + ].freeze end diff --git a/app/models/intervention.rb b/app/models/intervention.rb index 883a3b8bc1..ecc6fe821c 100644 --- a/app/models/intervention.rb +++ b/app/models/intervention.rb @@ -632,7 +632,7 @@ def participation(product) InterventionParticipation.of_intervention(self).of_product(product).first end - def drivers_times(nature: nil, not_nature: nil) + def worker_working_periods(nature: nil, not_nature: nil) participations.select { |participation| participation.product.is_a?(Worker) } working_periods = nil @@ -644,8 +644,11 @@ def drivers_times(nature: nil, not_nature: nil) working_periods = participations.map { |participation| participation.working_periods.where.not(nature: not_nature) } end - working_periods - .flatten + working_periods.flatten + end + + def drivers_times(nature: nil, not_nature: nil) + worker_working_periods .map(&:duration) .reduce(0, :+) end diff --git a/app/models/intervention_participation.rb b/app/models/intervention_participation.rb index e36cc75668..fa1a460a80 100644 --- a/app/models/intervention_participation.rb +++ b/app/models/intervention_participation.rb @@ -74,7 +74,7 @@ class InterventionParticipation < Ekylibre::Record::Base scope :sum_periods, lambda { |product_id, nature| InterventionParticipation.where(product_id: product_id, nature: nature) } - + scope :of_actor, ->(actor) { where(product_id: actor.id) } before_save do diff --git a/app/models/journal_entry.rb b/app/models/journal_entry.rb index 88d898f93b..1fddfd56d4 100644 --- a/app/models/journal_entry.rb +++ b/app/models/journal_entry.rb @@ -81,7 +81,7 @@ class IncompatibleCurrencies < StandardError; end # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`. validates :absolute_credit, :absolute_debit, :balance, :credit, :debit, :real_balance, :real_credit, :real_debit, presence: true, numericality: { greater_than: -1_000_000_000_000_000, less_than: 1_000_000_000_000_000 } - validates :absolute_currency,:currency, :journal, :real_currency, presence: true + validates :absolute_currency, :currency, :journal, :real_currency, presence: true validates :number, :state, presence: true, length: { maximum: 500 } validates :printed_on, presence: true, timeliness: { on_or_after: -> { Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.today + 50.years }, type: :date } validates :real_currency_rate, presence: true, numericality: { greater_than: -1_000_000_000, less_than: 1_000_000_000 } @@ -231,9 +231,7 @@ def self.states self.number ||= journal.next_number end - if financial_year.blank? - self.currency = absolute_currency - end + self.currency = absolute_currency if financial_year.blank? end validate(on: :update) do diff --git a/app/themes/tekyla/stylesheets/intervention_participations.scss b/app/themes/tekyla/stylesheets/intervention_participations.scss index 693bfd0bd6..ef2afe73ed 100644 --- a/app/themes/tekyla/stylesheets/intervention_participations.scss +++ b/app/themes/tekyla/stylesheets/intervention_participations.scss @@ -85,6 +85,11 @@ } } + .auto-calculate-equipments { + padding: 0 3em; + margin-top: 5em; + } + .modal-footer { .btn { diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 2473f9d4ae..7210048e17 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -1,6 +1,5 @@ - product_name = participation.product.nil? ? "" : participation.product.name = modal_header(t('labels.working_times', name: product_name)) -=# modal_header("Temps de travaux de \"#{ product_name }\"") = hidden_field_tag "intervention_participation[id]", participation.id = hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id @@ -27,6 +26,15 @@ - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) = render 'working_periods_fields', { working_period: pause_period } + - if auto_calcul_mode.to_sym == :true && participation.working_periods.empty? && !intervention_tool.nil? + - byebug + - if intervention_tool.product.tractor? + %span= intervention_tool.cost_amount_computation(nature: :intervention).quantity.round(1).l(precision: 0) + -# tool_period = InterventionWorkingPeriod.new(nature: :pause, + started_at: working_period.stopped_at, + stopped_at: working_period.next_period.started_at) + =# render 'working_periods_fields', { working_period: tool_period } + .actions = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :preparation } do =image_tag('intervention_participations/action-preparation.svg', class: "action-icon") @@ -44,6 +52,11 @@ .picto.picto-pause-circle-outline %span= I18n.t('enumerize.intervention_working_period.nature.pause') + - classes = 'hidden' if display_calcul_mode.to_sym == :false + %div{ class: "auto-calculate-equipments #{ classes }"} + = check_box 'participation', "auto_calculate_equipments", checked: true + %span Mode de calcul automatique + %p En mode automatique, les périodes de déplacement et d'intervention des tracteurs et outils seront calculés à partir de la moyenne des périodes des opérateurs. .modal-footer = button_tag :valid.tl, class: "btn btn-primary", id: "validParticipationsForm" diff --git a/app/views/backend/interventions/_product_parameter.html.haml b/app/views/backend/interventions/_product_parameter.html.haml index 8def7d6aa3..53be0c58fe 100644 --- a/app/views/backend/interventions/_product_parameter.html.haml +++ b/app/views/backend/interventions/_product_parameter.html.haml @@ -13,7 +13,7 @@ .period .period-type = image_tag('intervention_participations/action-preparation.svg', class: "period-icon") - %h3{ class: "period-label" }= t('enumerize.intervention_working_period.preparation') + %h3{ class: "period-label" }= t('enumerize.intervention_working_period.preparation') = add_working_period_cost(product_parameter, nature: :preparation) - if !participation.nil? && participation.has_period_with_nature?(nature: :travel) diff --git a/app/views/backend/interventions/_product_parameter_fields.html.haml b/app/views/backend/interventions/_product_parameter_fields.html.haml index 63832b1555..2e187c60a0 100644 --- a/app/views/backend/interventions/_product_parameter_fields.html.haml +++ b/app/views/backend/interventions/_product_parameter_fields.html.haml @@ -16,7 +16,7 @@ = f.referenced_association :product, label: reference.human_name, source: { scope: reference.scope_hash.merge(availables: [at: started_at.strftime("%Y-%m-%d %H:%M")]), keep: true }, input_html: { class: "scoped-parameter", data: { intervention_updater: prefix + 'product_id' } }, new: false - - if reference.doer? + - if reference.doer? || reference.tool? - if !f.object.new_record? - participation_picto = f.object.participation.nil? ? 'timer-off' : 'timer' - datas = { participation: f.object.participation.id } unless f.object.participation.nil? diff --git a/config/locales/arb/action.yml b/config/locales/arb/action.yml index 5799d6ea5f..c4efe06b11 100644 --- a/config/locales/arb/action.yml +++ b/config/locales/arb/action.yml @@ -2964,4 +2964,4 @@ arb: # backend/products: "%{work_number} %{name} (%{number})" # backend/purchase_payments: "%{number}. %{mode_name} to %{payee_full_name} of %{amount} %{currency}" # backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}" - # backend/users: "%{first_name} %{last_name}" + # backend/users: "%{first_name} %{last_name}" \ No newline at end of file diff --git a/config/locales/cmn/action.yml b/config/locales/cmn/action.yml index 00910cf677..dca007ba80 100644 --- a/config/locales/cmn/action.yml +++ b/config/locales/cmn/action.yml @@ -2187,4 +2187,4 @@ cmn: # backend/products: "%{work_number} %{name} (%{number})" # backend/purchase_payments: "%{number}. %{mode_name} to %{payee_full_name} of %{amount} %{currency}" # backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}" - # backend/users: "%{first_name} %{last_name}" + # backend/users: "%{first_name} %{last_name}" \ No newline at end of file diff --git a/config/locales/deu/action.yml b/config/locales/deu/action.yml index d96c8bbc5d..e74f3845cf 100644 --- a/config/locales/deu/action.yml +++ b/config/locales/deu/action.yml @@ -2185,4 +2185,4 @@ deu: # backend/products: "%{work_number} %{name} (%{number})" # backend/purchase_payments: "%{number}. %{mode_name} to %{payee_full_name} of %{amount} %{currency}" # backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}" - # backend/users: "%{first_name} %{last_name}" + # backend/users: "%{first_name} %{last_name}" \ No newline at end of file diff --git a/config/locales/fra/action.yml b/config/locales/fra/action.yml index c91f985180..71d18bb7a6 100644 --- a/config/locales/fra/action.yml +++ b/config/locales/fra/action.yml @@ -2828,4 +2828,4 @@ fra: backend/products: "%{work_number} %{name} (%{number}) - %{container_name}" backend/purchase_payments: "%{number}. %{mode_name} pour %{payee_full_name} de %{amount} %{currency}" backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}" - backend/users: "%{first_name} %{last_name}" + backend/users: "%{first_name} %{last_name}" \ No newline at end of file diff --git a/config/locales/fra/aggregators.yml b/config/locales/fra/aggregators.yml index fc8b3ea395..f0701dd86f 100644 --- a/config/locales/fra/aggregators.yml +++ b/config/locales/fra/aggregators.yml @@ -4,6 +4,7 @@ fra: started_on: "Débuté le" stopped_on: "Arrếté on" aggregator_properties: + active: "Actif" #? activity_family: "Famille d'activité" #? actor_name: "Nom de l'acteur" #? animal_group_name: "Nom du groupe d'animaux" #? @@ -14,17 +15,16 @@ fra: born_at: "Né(e) à" breeding_number: "Numéro d'élevage" campaigns: "Campagnes" - catalog_name: "Nom du catalogue" capitalised_production: "Production capitalisée" #? + catalog_name: "Nom du catalogue" #? + charge_account_label: "Étiquette du compte de frais" #? company: "Entreprise" container_name: "Nom de l'emplacement" current_result_before_taxes: "Résultat en cours avant taxes" - derivative: "Dérivé" - active: "Actif" depreciations_inputations_expenses: "Charges des imputations des dépréciations" #? - doer: "Opérateur" + derivative: "Dérivé" #? + doer: "Opérateur" #? doer_cost: "Cout de main d'oeuvre" - charge_account_label: "Étiquette du compte de frais" doer_name: "Acteur" doers_name: "Nom des acteurs" duration_in_hour: "Durée (heures)" @@ -83,7 +83,7 @@ fra: pasturing_period: "Période pâturage" #? pasturing_working_area: "Zone de pâturage" #? payment_ratio: "Ratio de paiement" - person_name: "Nom" + person_name: "Nom" #? pictogram: "Pictogramme" picture_path: "Chemin d'image" # plan: "Plan" @@ -113,7 +113,7 @@ fra: social_expenses: "Charges sociales" #? soil_varieties: "Variétés de sol" #? sowed_at: "Semé le" #? - stock_account_label: "Étiquette du compte de stock" + stock_account_label: "Étiquette du compte de stock" #? stock_production: "Production de stock" #? stocks_variation: "Variation de stocks" #? subsidies: "Subventions" #? @@ -124,6 +124,6 @@ fra: vine_yield: "Rendement en vin" wages: "Salaires" #? working_area: "Superficie travaillée" - working_duration_in_hours: "Durée travaillée en heures" + working_duration_in_hours: "Durée travaillée en heures" #? aggregators: #? vat_register: "Registre de TVA" #? \ No newline at end of file diff --git a/config/locales/ita/action.yml b/config/locales/ita/action.yml index 976eed72c0..a9a57ab931 100644 --- a/config/locales/ita/action.yml +++ b/config/locales/ita/action.yml @@ -2252,4 +2252,4 @@ ita: # backend/products: "%{work_number} %{name} (%{number})" # backend/purchase_payments: "%{number}. %{mode_name} to %{payee_full_name} of %{amount} %{currency}" # backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}" - # backend/users: "%{first_name} %{last_name}" + # backend/users: "%{first_name} %{last_name}" \ No newline at end of file diff --git a/config/locales/jpn/action.yml b/config/locales/jpn/action.yml index ab8fb435f2..b39eef3355 100644 --- a/config/locales/jpn/action.yml +++ b/config/locales/jpn/action.yml @@ -2262,4 +2262,4 @@ jpn: # backend/products: "%{work_number} %{name} (%{number})" # backend/purchase_payments: "%{number}. %{mode_name} to %{payee_full_name} of %{amount} %{currency}" # backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}" - # backend/users: "%{first_name} %{last_name}" + # backend/users: "%{first_name} %{last_name}" \ No newline at end of file diff --git a/config/locales/por/action.yml b/config/locales/por/action.yml index 9676e99a8c..49f8722452 100644 --- a/config/locales/por/action.yml +++ b/config/locales/por/action.yml @@ -2191,4 +2191,4 @@ por: backend/products: "%{work_number} %{name} (%{number})" backend/purchase_payments: "%{number}. %{mode_name} %{payee_full_name} %{amount} %{currency}" backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}" - backend/users: "%{first_name} %{last_name}" + backend/users: "%{first_name} %{last_name}" \ No newline at end of file diff --git a/config/locales/spa/action.yml b/config/locales/spa/action.yml index 90cb84871c..7343aae0e4 100644 --- a/config/locales/spa/action.yml +++ b/config/locales/spa/action.yml @@ -2479,4 +2479,4 @@ spa: # backend/products: "%{work_number} %{name} (%{number})" # backend/purchase_payments: "%{number}. %{mode_name} to %{payee_full_name} of %{amount} %{currency}" # backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}" - # backend/users: "%{first_name} %{last_name}" + # backend/users: "%{first_name} %{last_name}" \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 1649b5fdfd..9f2cfb4525 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2,7 +2,7 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.3 +-- Dumped from database version 9.5.7 -- Dumped by pg_dump version 9.6.3 SET statement_timeout = 0; From 0fa55a177f2a56271e5c3f5fd9064b8e9771f0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Mon, 24 Jul 2017 09:28:36 +0200 Subject: [PATCH 12/38] Add auto calcul mode --- Gemfile | 2 +- Gemfile.lock | 4 ++-- .../backend/interventions.js.coffee | 4 ++++ .../intervention_participations_controller.rb | 12 +++++++++- app/models/document.rb | 2 +- app/models/intervention.rb | 7 +++++- .../_participations_modal.html.haml | 23 +++++++++++-------- 7 files changed, 38 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index fa18817bdd..58a453ca09 100644 --- a/Gemfile +++ b/Gemfile @@ -192,7 +192,7 @@ gem 'luhn' gem 'bootstrap-slider-rails' group :development do - gem 'bullet' + gem 'bullet', '< 5.6.0' gem 'quiet_assets' # gem 'rack-mini-profiler' diff --git a/Gemfile.lock b/Gemfile.lock index 2c14afeeb6..c3d3a9f0ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,7 +96,7 @@ GEM momentjs-rails (>= 2.8.1) browser (2.4.0) builder (3.2.3) - bullet (5.6.0) + bullet (5.5.1) activesupport (>= 3.0.0) uniform_notifier (~> 1.10.0) burisu-docsplit (0.7.9) @@ -589,7 +589,7 @@ DEPENDENCIES bootstrap-slider-rails bootstrap3-datetimepicker-rails browser - bullet + bullet (< 5.6.0) capybara capybara-webkit charlock_holmes diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index 086f0d6601..e4a0b590b8 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -199,6 +199,10 @@ participations = $('intervention_participation') interventionStartedAt = null + participations = [] + $('.intervention-participation').each -> + participations.push($(this).val()) + if intervention_id == "" interventionStartedAt = $('.intervention-started-at').val() diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index 3b51b462a3..8c865494ab 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -74,13 +74,23 @@ def participations_modal display_calcul_mode = params[:display_calcul_mode] auto_calcul_mode = params[:auto_calcul_mode] + form_participations = [] + if params[:participations].present? + params[:participations].each do |participation| + form_participations << InterventionParticipation.new(JSON.parse(participation)) + end + #form_participations = params[:participations] + # .map{ |participation| InterventionParticipation.new(JSON.parse(participation)) } + end + render partial: 'backend/intervention_participations/participations_modal', locals: { participation: participation, intervention_started_at: intervention_started_at, intervention_tool: intervention_tool, display_calcul_mode: display_calcul_mode, - auto_calcul_mode: auto_calcul_mode + auto_calcul_mode: auto_calcul_mode, + form_participations: form_participations } end diff --git a/app/models/document.rb b/app/models/document.rb index d444961143..f97603ba42 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -55,7 +55,7 @@ class Document < Ekylibre::Record::Base } refers_to :nature, class_name: 'DocumentNature' # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`. - validates :file_content_text, length: { maximum: 500_000 }, allow_blank: true + validates :file_content_text, length: { maximum: 5_000_000 }, allow_blank: true validates :file_content_type, :file_file_name, :file_fingerprint, length: { maximum: 500 }, allow_blank: true validates :file_file_size, numericality: { only_integer: true, greater_than: -2_147_483_649, less_than: 2_147_483_648 }, allow_blank: true validates :file_updated_at, timeliness: { on_or_after: -> { Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.now + 50.years } }, allow_blank: true diff --git a/app/models/intervention.rb b/app/models/intervention.rb index ecc6fe821c..b2a52d7190 100644 --- a/app/models/intervention.rb +++ b/app/models/intervention.rb @@ -648,11 +648,16 @@ def worker_working_periods(nature: nil, not_nature: nil) end def drivers_times(nature: nil, not_nature: nil) - worker_working_periods + worker_working_periods(nature: nature, not_nature: not_nature) .map(&:duration) .reduce(0, :+) end + def first_worker_working_period(nature: nil, not_nature: nil) + test = worker_working_periods(nature: nature, not_nature: not_nature) + byebug + end + class << self def used_procedures select(:procedure_name).distinct.pluck(:procedure_name).map do |name| diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 7210048e17..3e5cf36e02 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -19,21 +19,24 @@ %h3{ class: "action-header action-period" }= :action_duration.tl %h3{ class: "action-header" }= :calculated_hours.tl - - participation.working_periods.each do |working_period| - = render 'working_periods_fields', { working_period: working_period } - - if working_period.pause_next? - - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) - = render 'working_periods_fields', { working_period: pause_period } - - - if auto_calcul_mode.to_sym == :true && participation.working_periods.empty? && !intervention_tool.nil? - - byebug + - if auto_calcul_mode.to_sym == :true && !form_participations.nil? && !intervention_tool.nil? - if intervention_tool.product.tractor? + - byebug %span= intervention_tool.cost_amount_computation(nature: :intervention).quantity.round(1).l(precision: 0) - -# tool_period = InterventionWorkingPeriod.new(nature: :pause, + - tool_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) - =# render 'working_periods_fields', { working_period: tool_period } + = render 'working_periods_fields', { working_period: tool_period } + + - elsif !participation.nil? + - participation.working_periods.each do |working_period| + = render 'working_periods_fields', { working_period: working_period } + + - if working_period.pause_next? + - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) + = render 'working_periods_fields', { working_period: pause_period } + .actions = button_tag nil, { class: "btn btn-default action", 'data-nature-period': :preparation } do From 11e274bb92036faf4998fddc298a6a835efb4d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Mon, 31 Jul 2017 14:51:53 +0200 Subject: [PATCH 13/38] Add Working duration service --- .../intervention_participations_controller.rb | 22 ++-- .../interventions/working_duration_service.rb | 103 ++++++++++++++++++ .../_participations_modal.html.haml | 14 +-- 3 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 app/services/interventions/working_duration_service.rb diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index 8c865494ab..ee21a65537 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -60,27 +60,35 @@ def participations_modal ) end - intervention_started_at = if participation.intervention.nil? + intervention = participation.intervention + + intervention_started_at = if intervention.nil? Time.parse(params['intervention_started_at']) else - participation.intervention.started_at + intervention.started_at end intervention_tool = nil if Product.find(params[:product_id]).is_a?(Equipment) - intervention_tool = participation.intervention.tools.find_by(product_id: params[:product_id]) + intervention_tool = intervention.tools.find_by(product_id: params[:product_id]) end display_calcul_mode = params[:display_calcul_mode] auto_calcul_mode = params[:auto_calcul_mode] + participations = intervention.participations + calculate_working_periods = [] form_participations = [] if params[:participations].present? - params[:participations].each do |participation| - form_participations << InterventionParticipation.new(JSON.parse(participation)) + params[:participations].each do |form_participation| + form_participations << InterventionParticipation.new(JSON.parse(form_participation)) end - #form_participations = params[:participations] - # .map{ |participation| InterventionParticipation.new(JSON.parse(participation)) } + + Interventions::WorkingDurationService + .new(intervention: intervention, + participations: form_participations, + product: participation.product) + .duration_in_hours(nature: :travel) end render partial: 'backend/intervention_participations/participations_modal', diff --git a/app/services/interventions/working_duration_service.rb b/app/services/interventions/working_duration_service.rb new file mode 100644 index 0000000000..eef7675a0e --- /dev/null +++ b/app/services/interventions/working_duration_service.rb @@ -0,0 +1,103 @@ +module Interventions + class WorkingDurationService + attr_reader :intervention, :participations, :product + + def initialize(intervention: nil, participations: {}, product: nil) + @intervention = intervention + @participations = participations + @product = product + end + + def duration(nature: nil, not_nature: nil) + return @intervention.working_duration if @participations.empty? + + if worker? + return @participations + .map{|participation| participation.working_periods.sum(:duration) } + .inject(0, :+) + end + + times = workers_times(nature: nature, not_nature: not_nature) + + if times == 0 || + (tractors_count == 0 && prepelled_equipments_count == 0) + return @intervention.working_duration + end + + times / (tractors_count + prepelled_equipments_count) + end + + def duration_in_hours(nature: nil, not_nature: nil) + quantity = duration(nature: nature, not_nature: not_nature).to_d / 3600 + + unit_name = Nomen::Unit.find(:hour).human_name + unit_name = unit_name.pluralize if quantity > 1 + + options = { + catalog_usage: worker? ? :cost : :travel_cost, + quantity: quantity, + unit_name: unit_name + } + + options[:catalog_item] = @product.default_catalog_item(options[:catalog_usage]) + byebug + InterventionParameter::AmountComputation.quantity(:catalog, options) + end + + private + + def worker? + @product.is_a?(Worker) + end + + def tractors_count + @participations + .select{ |participation| participation.product.try(:tractor?) } + .size + end + + def prepelled_equipments_count + @participations + .select{ |participation| participation.product.variety.to_sym == :self_prepelled_equipment } + .size + end + + def workers_times(nature: nil, not_nature: nil) + byebug + worker_working_periods(nature, not_nature) + .map(&:duration) + .reduce(0, :+) + end + + def worker_working_periods(nature, not_nature) + participations = @participations.select{ |participation| participation.product.is_a?(Worker) } + working_periods = nil + + if nature.nil? && not_nature.nil? + return participations.map(&:working_periods).flatten + end + + unless nature.nil? + return working_periods_of_nature(participations, nature) + end + + working_periods_not_nature(participations, nature) + end + + def working_periods_of_nature(participations, nature, reverse_result: false) + participations.map do |participation| + participation.working_periods.select do |working_period| + if reverse_result == false + working_period.nature.to_sym == nature + else + working_period.nature.to_sym != nature + end + end + end.flatten + end + + def working_periods_not_nature(participations, nature) + working_periods_of_nature(participations, nature, reverse_result: true) + end + end +end \ No newline at end of file diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 3e5cf36e02..a6198f512f 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -20,7 +20,7 @@ %h3{ class: "action-header" }= :calculated_hours.tl - - if auto_calcul_mode.to_sym == :true && !form_participations.nil? && !intervention_tool.nil? + -# if auto_calcul_mode.to_sym == :true && !form_participations.nil? && !intervention_tool.nil? - if intervention_tool.product.tractor? - byebug %span= intervention_tool.cost_amount_computation(nature: :intervention).quantity.round(1).l(precision: 0) @@ -29,13 +29,13 @@ stopped_at: working_period.next_period.started_at) = render 'working_periods_fields', { working_period: tool_period } - - elsif !participation.nil? - - participation.working_periods.each do |working_period| - = render 'working_periods_fields', { working_period: working_period } + -# elsif !participation.nil? + - participation.working_periods.each do |working_period| + = render 'working_periods_fields', { working_period: working_period } - - if working_period.pause_next? - - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) - = render 'working_periods_fields', { working_period: pause_period } + - if working_period.pause_next? + - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) + = render 'working_periods_fields', { working_period: pause_period } .actions From 3274c5f7348d562a91190d0567812139af585397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Tue, 1 Aug 2017 07:58:40 +0200 Subject: [PATCH 14/38] Correct errors on working duration service --- .../interventions/working_duration_service.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/services/interventions/working_duration_service.rb b/app/services/interventions/working_duration_service.rb index eef7675a0e..bfd550fbb8 100644 --- a/app/services/interventions/working_duration_service.rb +++ b/app/services/interventions/working_duration_service.rb @@ -19,11 +19,15 @@ def duration(nature: nil, not_nature: nil) times = workers_times(nature: nature, not_nature: not_nature) + byebug + if times == 0 || (tractors_count == 0 && prepelled_equipments_count == 0) return @intervention.working_duration end + byebug + times / (tractors_count + prepelled_equipments_count) end @@ -50,6 +54,18 @@ def worker? @product.is_a?(Worker) end + def tractor? + @product.is_a?(Equipment) && @product.try(:tractor?) + end + + def self_prepelled_equipment? + @product.variety.to_sym == :self_prepelled_equipment + end + + def tool? + @product.is_a?(Equipment) + end + def tractors_count @participations .select{ |participation| participation.product.try(:tractor?) } @@ -63,9 +79,8 @@ def prepelled_equipments_count end def workers_times(nature: nil, not_nature: nil) - byebug worker_working_periods(nature, not_nature) - .map(&:duration) + .map(&:hours_gap) .reduce(0, :+) end From 50aca5b9d14e9be503c5704e2470e62d8af315a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 3 Aug 2017 17:27:07 +0200 Subject: [PATCH 15/38] Change tractor count method --- app/services/interventions/working_duration_service.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/services/interventions/working_duration_service.rb b/app/services/interventions/working_duration_service.rb index bfd550fbb8..3e7206886b 100644 --- a/app/services/interventions/working_duration_service.rb +++ b/app/services/interventions/working_duration_service.rb @@ -67,9 +67,15 @@ def tool? end def tractors_count - @participations + count = @participations .select{ |participation| participation.product.try(:tractor?) } .size + + if tractor? + count++ + end + + count end def prepelled_equipments_count From af1e9778ce3b16328e0a309402a710868210ba40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Tue, 8 Aug 2017 12:40:46 +0200 Subject: [PATCH 16/38] Resolve last bugs for intervention times --- .../intervention_participations.js.coffee | 6 +- .../backend/interventions.js.coffee | 2 + .../intervention_participations_controller.rb | 95 +++++++++++++------ app/models/intervention_agent.rb | 21 ++-- app/models/intervention_doer.rb | 6 ++ .../interventions/working_duration_service.rb | 80 +++++++++------- .../intervention_participations.scss | 2 +- .../_participations_modal.html.haml | 30 +++--- .../_intervention_costs.html.haml | 2 +- 9 files changed, 154 insertions(+), 90 deletions(-) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index de324b99c8..1f7fda3afe 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -102,7 +102,7 @@ $('.edit_intervention, .new_intervention').find('.form-fields').append('') - concernedProductField = $('.nested-doers .nested-fields .selector .selector-value[value="' + participation.product_id + '"]') + concernedProductField = $('.nested-fields .selector .selector-value[value="' + participation.product_id + '"]') nestedFieldBlock = concernedProductField.closest('.nested-fields') productFieldPicto = nestedFieldBlock.find('.picto-timer-off') @@ -117,8 +117,12 @@ $(document).on "keyup", '#working_times .participations input[type="text"]', (event) -> element = $(event.target) + if $('#working_times #intervention_tool').length == 1 + $('input[name="auto-calcul-mode"]').val("false") + E.interventionParticipations.changeWorkingPeriod(element) + $(document).on "click", '#participation_auto_calculate_equipments', (event) -> isChecked = $(event.target).is(':checked') diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index e4a0b590b8..f0f94cf4eb 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -214,6 +214,8 @@ autoCalculMode = true if $('input[name="auto-calcul-mode"]').length == 0 $('.simple_form').append('') + #else if existingParticipation && existingParticipation != "" + #autoCalculMode = false else autoCalculMode = $('input[name="auto-calcul-mode"]').val() diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index ee21a65537..a366fb07ac 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -48,64 +48,99 @@ def convert end def participations_modal - participation = nil + @participation = nil if params['existing_participation'].present? json_participation = JSON.parse(params['existing_participation']) - participation = InterventionParticipation.new(json_participation) + @participation = InterventionParticipation.new(json_participation) else - participation = InterventionParticipation.find_or_initialize_by( + @participation = InterventionParticipation.find_or_initialize_by( product_id: params[:product_id], intervention_id: params[:intervention_id] ) end - intervention = participation.intervention + @intervention = @participation.intervention - intervention_started_at = if intervention.nil? + intervention_started_at = if @intervention.nil? Time.parse(params['intervention_started_at']) else - intervention.started_at + @intervention.started_at end - intervention_tool = nil - if Product.find(params[:product_id]).is_a?(Equipment) - intervention_tool = intervention.tools.find_by(product_id: params[:product_id]) - end - display_calcul_mode = params[:display_calcul_mode] auto_calcul_mode = params[:auto_calcul_mode] - participations = intervention.participations - calculate_working_periods = [] - form_participations = [] - if params[:participations].present? - params[:participations].each do |form_participation| - form_participations << InterventionParticipation.new(JSON.parse(form_participation)) - end - - Interventions::WorkingDurationService - .new(intervention: intervention, - participations: form_participations, - product: participation.product) - .duration_in_hours(nature: :travel) - end - render partial: 'backend/intervention_participations/participations_modal', locals: { - participation: participation, + participation: @participation, intervention_started_at: intervention_started_at, - intervention_tool: intervention_tool, + tool: intervention_tool, display_calcul_mode: display_calcul_mode, auto_calcul_mode: auto_calcul_mode, - form_participations: form_participations + calculate_working_periods: calculate_working_periods } end private def permitted_params - params[:intervention_participation].permit(:intervention_id, :product_id, working_periods_attributes: %i[id started_at stopped_at nature]) + params[:intervention_participation].permit(:intervention_id, + :product_id, + working_periods_attributes: %i[id started_at stopped_at nature]) + end + + def form_participations + form_participations = [] + + return form_participations if params[:participations].blank? + + params[:participations].each do |form_participation| + form_participations << InterventionParticipation.new(JSON.parse(form_participation)) + end + + form_participations + end + + def intervention_tool + product = Product.find(params[:product_id]) + + return nil unless product.is_a?(Equipment) + + product + end + + def calculate_working_periods + participations = form_participations + tool = intervention_tool + auto_calcul_mode = params[:auto_calcul_mode] + + return [] if auto_calcul_mode.to_sym == :false || + participations.blank? || tool.nil? + + working_periods = [] + intervention_started_at = @intervention.started_at + working_duration_params = { intervention: @intervention, + participations: participations, + product: @participation.product } + + natures = %i[travel intervention] if tool.try(:tractor?) + natures = %i[intervention] unless tool.try(:tractor?) + + natures.each do |nature| + duration = Interventions::WorkingDurationService + .new(**working_duration_params) + .perform(nature: nature) + + stopped_at = intervention_started_at + (duration * 60 * 60) + + working_periods << InterventionWorkingPeriod + .new(nature: nature, + started_at: intervention_started_at, + stopped_at: stopped_at) + end + + working_periods end end end diff --git a/app/models/intervention_agent.rb b/app/models/intervention_agent.rb index bae7c56f81..6fbb9a68f4 100644 --- a/app/models/intervention_agent.rb +++ b/app/models/intervention_agent.rb @@ -70,21 +70,14 @@ def participation end end - # compute working duration from participation if exist or from intervention directly - def working_duration(nature: nil) - if participation - participation.working_periods.sum(:duration) - else - intervention_working_duration - end - end - def cost_amount_computation(nature: nil) return InterventionParameter::AmountComputation.failed unless product - quantity = working_duration(nature: nature).to_d / 3600 - unit_name = Nomen::Unit.find(:hour).human_name + quantity = Interventions::WorkingDurationService + .new(**working_duration_params) + .perform(nature: nature) + unit_name = Nomen::Unit.find(:hour).human_name unit_name = unit_name.pluralize if quantity > 1 options = { @@ -96,6 +89,12 @@ def cost_amount_computation(nature: nil) InterventionParameter::AmountComputation.quantity(:catalog, options) end + def working_duration_params + { intervention: intervention, + participations: intervention.participations, + product: product } + end + def catalog_usage :cost end diff --git a/app/models/intervention_doer.rb b/app/models/intervention_doer.rb index bc335368e5..afecf0f479 100644 --- a/app/models/intervention_doer.rb +++ b/app/models/intervention_doer.rb @@ -85,4 +85,10 @@ def working_duration(nature: nil) participation.sum_periods_of_nature(nature) end + + def working_duration_params + { intervention: intervention, + participation: participation, + product: product } + end end diff --git a/app/services/interventions/working_duration_service.rb b/app/services/interventions/working_duration_service.rb index 3e7206886b..3ef3cf6b0b 100644 --- a/app/services/interventions/working_duration_service.rb +++ b/app/services/interventions/working_duration_service.rb @@ -1,55 +1,53 @@ module Interventions class WorkingDurationService - attr_reader :intervention, :participations, :product + attr_reader :intervention, :participations, :participation, :product - def initialize(intervention: nil, participations: {}, product: nil) + def initialize(intervention: nil, participations: [], participation: nil, product: nil) @intervention = intervention @participations = participations + @participation = participation @product = product end - def duration(nature: nil, not_nature: nil) - return @intervention.working_duration if @participations.empty? + def perform(nature: nil, not_nature: nil) + return @intervention.working_duration.to_d / 3600 if @participations.empty? && @participation.nil? - if worker? - return @participations - .map{|participation| participation.working_periods.sum(:duration) } - .inject(0, :+) - end + return worker_working_duration(nature) if worker? times = workers_times(nature: nature, not_nature: not_nature) - byebug - if times == 0 || - (tractors_count == 0 && prepelled_equipments_count == 0) + (tractors_count == 0 && prepelled_equipments_count == 0 && tools_count == 0) return @intervention.working_duration end - byebug + if tool? + return times.to_d / tools_count + end - times / (tractors_count + prepelled_equipments_count) + times.to_d / (tractors_count + prepelled_equipments_count) end - def duration_in_hours(nature: nil, not_nature: nil) - quantity = duration(nature: nature, not_nature: not_nature).to_d / 3600 - unit_name = Nomen::Unit.find(:hour).human_name - unit_name = unit_name.pluralize if quantity > 1 - - options = { - catalog_usage: worker? ? :cost : :travel_cost, - quantity: quantity, - unit_name: unit_name - } + private - options[:catalog_item] = @product.default_catalog_item(options[:catalog_usage]) - byebug - InterventionParameter::AmountComputation.quantity(:catalog, options) + def worker_working_duration(nature) + duration = if nature.nil? + @participation + .working_periods + .map(&:duration) + .inject(0, :+) + else + @participation + .working_periods + .select{ |working_period| working_period.nature.to_sym == nature } + .map(&:duration) + .inject(0, :+) + end + + duration / 3600 end - private - def worker? @product.is_a?(Worker) end @@ -63,7 +61,7 @@ def self_prepelled_equipment? end def tool? - @product.is_a?(Equipment) + @product.is_a?(Equipment) && product.try(:tractor?) == false end def tractors_count @@ -71,13 +69,31 @@ def tractors_count .select{ |participation| participation.product.try(:tractor?) } .size - if tractor? - count++ + if tractor? && !product_participation? + count += 1 + end + + count + end + + def tools_count + count = @participations + .select{ |participation| participation.product.is_a?(Equipment) && participation.product.try(:tractor?) == false } + .size + + if !tractor? && tool? && !product_participation? + count += 1 end count end + def product_participation? + @participations + .select{ |participation| participation.product == @product } + .present? + end + def prepelled_equipments_count @participations .select{ |participation| participation.product.variety.to_sym == :self_prepelled_equipment } diff --git a/app/themes/tekyla/stylesheets/intervention_participations.scss b/app/themes/tekyla/stylesheets/intervention_participations.scss index ef2afe73ed..32b161fa55 100644 --- a/app/themes/tekyla/stylesheets/intervention_participations.scss +++ b/app/themes/tekyla/stylesheets/intervention_participations.scss @@ -87,7 +87,7 @@ .auto-calculate-equipments { padding: 0 3em; - margin-top: 5em; + margin-top: 3em; } .modal-footer { diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index a6198f512f..5d87d9d08a 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -5,6 +5,7 @@ = hidden_field_tag "intervention_participation[intervention_id]", participation.intervention_id = hidden_field_tag "intervention_participation[product_id]", participation.product_id = hidden_field_tag 'intervention_started_at', intervention_started_at.iso8601 += hidden_field_tag 'intervention_tool', !tool.nil? unless tool.nil? .modal-body .indicators @@ -20,22 +21,19 @@ %h3{ class: "action-header" }= :calculated_hours.tl - -# if auto_calcul_mode.to_sym == :true && !form_participations.nil? && !intervention_tool.nil? - - if intervention_tool.product.tractor? - - byebug - %span= intervention_tool.cost_amount_computation(nature: :intervention).quantity.round(1).l(precision: 0) - - tool_period = InterventionWorkingPeriod.new(nature: :pause, - started_at: working_period.stopped_at, - stopped_at: working_period.next_period.started_at) - = render 'working_periods_fields', { working_period: tool_period } + - if auto_calcul_mode.to_sym == :true && !calculate_working_periods.blank? + - calculate_working_periods.each do |calculate_working_period| + = render 'working_periods_fields', { working_period: calculate_working_period } - -# elsif !participation.nil? - - participation.working_periods.each do |working_period| - = render 'working_periods_fields', { working_period: working_period } + - elsif !participation.nil? + - participation.working_periods.each do |working_period| + = render 'working_periods_fields', { working_period: working_period } - - if working_period.pause_next? - - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) - = render 'working_periods_fields', { working_period: pause_period } + - if working_period.pause_next? + - pause_period = InterventionWorkingPeriod.new(nature: :pause, + started_at: working_period.stopped_at, + stopped_at: working_period.next_period.started_at) + = render 'working_periods_fields', { working_period: pause_period } .actions @@ -61,6 +59,10 @@ %span Mode de calcul automatique %p En mode automatique, les périodes de déplacement et d'intervention des tracteurs et outils seront calculés à partir de la moyenne des périodes des opérateurs. + - unless tool.nil? + %div{ class: "auto-calculate-equipments"} + %p Une modification manuelle désactivera le mode de calcul automatique. + .modal-footer = button_tag :valid.tl, class: "btn btn-primary", id: "validParticipationsForm" = button_tag :cancel.tl, class: "btn btn-default", data: { dismiss: 'modal' } diff --git a/app/views/backend/interventions/_intervention_costs.html.haml b/app/views/backend/interventions/_intervention_costs.html.haml index 4c47bfae18..cf3cc02b70 100644 --- a/app/views/backend/interventions/_intervention_costs.html.haml +++ b/app/views/backend/interventions/_intervention_costs.html.haml @@ -7,7 +7,7 @@ - elsif computation.none? = '—'.html_safe - elsif computation.quantity? - %span.quantity= computation.quantity.round(1).l(precision: 0) + %span.quantity= computation.quantity.round(3).l(precision: 0) %span.unit-name= computation.unit_name %span x - if computation.sale? From 1d4bb7220c8138a1e660efa5db24e605d9bf8a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Tue, 8 Aug 2017 13:55:04 +0200 Subject: [PATCH 17/38] Remove merge conflict (oops) --- Gemfile.lock | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 64e666fee1..7c04f68f71 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,7 +65,7 @@ GEM sidekiq (>= 2.11) arel (6.0.4) ast (2.3.0) - autoprefixer-rails (7.1.2.3) + autoprefixer-rails (7.1.2.4) execjs awesome_nested_set (3.1.3) activerecord (>= 4.0.0, < 5.2) @@ -456,7 +456,7 @@ GEM selenium-webdriver (3.4.4) childprocess (~> 0.5) rubyzip (~> 1.0) - sentry-raven (2.6.2) + sentry-raven (2.6.3) faraday (>= 0.7.6, < 1.0) sepa_king (0.9.0) activemodel (>= 3.0.0) @@ -518,9 +518,7 @@ GEM rack (>= 1, < 3) thor (0.19.4) thread_safe (0.3.6) - time_diff (0.3.0) - activesupport - i18n + tilt (2.0.8) timecop (0.9.1) timeliness (0.3.8) tins (1.15.0) @@ -588,11 +586,7 @@ DEPENDENCIES bootstrap-slider-rails bootstrap3-datetimepicker-rails browser -<<<<<<< HEAD bullet (< 5.6.0) -======= - bullet (~> 5.5.0) ->>>>>>> a0cf9a99e45e0839be671ad8f564ddbe2aee227e capybara capybara-webkit charlock_holmes From 916b9886ea9a6058ae85365a027c794ef5baf1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Wed, 9 Aug 2017 10:35:30 +0200 Subject: [PATCH 18/38] Resolve mass erase and bugs after merge with master --- Gemfile | 3 + Gemfile.lock | 6 +- .../action-intervention.svg | 90 +++++++++++++++++++ .../action-preparation.svg | 90 +++++++++++++++++++ .../action-travel.svg | 90 +++++++++++++++++++ app/assets/javascripts/i18n/ext.coffee | 5 ++ app/assets/javascripts/i18n/translations.js | 18 ++-- app/helpers/backend/interventions_helper.rb | 8 ++ app/models/catalog.rb | 2 +- app/models/document.rb | 2 +- app/models/entity.rb | 1 + app/models/equipment.rb | 8 ++ app/models/intervention.rb | 3 - app/models/intervention_agent.rb | 10 +-- app/models/intervention_parameter.rb | 5 ++ app/models/intervention_participation.rb | 8 ++ app/models/intervention_working_period.rb | 55 +++++++++++- app/themes/tekyla/stylesheets/all.scss | 1 + .../tekyla/stylesheets/interventions.scss | 1 + .../backend/interventions/_form.html.haml | 2 + .../_intervention_total_costs.html.haml | 16 ++++ .../_product_parameter.html.haml | 35 -------- config/locales/arb/action.yml | 2 + config/locales/arb/enumerize.yml | 1 + config/locales/arb/support.yml | 4 + config/locales/cmn/action.yml | 2 + config/locales/cmn/enumerize.yml | 1 + config/locales/cmn/support.yml | 4 + config/locales/deu/action.yml | 2 + config/locales/deu/enumerize.yml | 1 + config/locales/deu/support.yml | 4 + config/locales/eng/action.yml | 2 + config/locales/eng/enumerize.yml | 2 + config/locales/eng/support.yml | 4 + config/locales/fra/action.yml | 2 + config/locales/fra/aggregators.yml | 12 +-- config/locales/fra/enumerize.yml | 2 + config/locales/fra/support.yml | 4 + config/locales/ita/action.yml | 2 + config/locales/ita/enumerize.yml | 1 + config/locales/ita/support.yml | 4 + config/locales/jpn/action.yml | 2 + config/locales/jpn/enumerize.yml | 1 + config/locales/jpn/support.yml | 4 + config/locales/por/action.yml | 2 + config/locales/por/enumerize.yml | 1 + config/locales/por/support.yml | 4 + config/locales/spa/action.yml | 2 + config/locales/spa/enumerize.yml | 1 + config/locales/spa/support.yml | 4 + config/navigation.xml | 1 + config/rights.yml | 1 - config/routes.rb | 6 +- 53 files changed, 478 insertions(+), 66 deletions(-) create mode 100644 app/assets/images/intervention_participations/action-intervention.svg create mode 100644 app/assets/images/intervention_participations/action-preparation.svg create mode 100644 app/assets/images/intervention_participations/action-travel.svg create mode 100644 app/views/backend/interventions/_intervention_total_costs.html.haml diff --git a/Gemfile b/Gemfile index badda5f256..ce68648707 100644 --- a/Gemfile +++ b/Gemfile @@ -132,6 +132,9 @@ gem 'humanize' gem 'i18n-complements', '>= 0.0.14' gem 'i18n-js', '>= 3.0.0.rc12' +# Dates management +gem 'time_diff' + # XML Parsing/Writing, HTML extraction gem 'nokogiri', '~> 1.7.1' diff --git a/Gemfile.lock b/Gemfile.lock index 7c04f68f71..ca1d0e6eab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,7 +94,7 @@ GEM railties (>= 3.2, < 6.0) bootstrap3-datetimepicker-rails (4.17.47) momentjs-rails (>= 2.8.1) - browser (2.4.0) + browser (2.5.0) builder (3.2.3) bullet (5.5.1) activesupport (>= 3.0.0) @@ -519,6 +519,9 @@ GEM thor (0.19.4) thread_safe (0.3.6) tilt (2.0.8) + time_diff (0.3.0) + activesupport + i18n timecop (0.9.1) timeliness (0.3.8) tins (1.15.0) @@ -674,6 +677,7 @@ DEPENDENCIES teaspoon-jasmine therubyracer thin + time_diff timecop treetop turbolinks (~> 2.0) diff --git a/app/assets/images/intervention_participations/action-intervention.svg b/app/assets/images/intervention_participations/action-intervention.svg new file mode 100644 index 0000000000..ce91421c7c --- /dev/null +++ b/app/assets/images/intervention_participations/action-intervention.svg @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/assets/images/intervention_participations/action-preparation.svg b/app/assets/images/intervention_participations/action-preparation.svg new file mode 100644 index 0000000000..8f56ce5bd0 --- /dev/null +++ b/app/assets/images/intervention_participations/action-preparation.svg @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/assets/images/intervention_participations/action-travel.svg b/app/assets/images/intervention_participations/action-travel.svg new file mode 100644 index 0000000000..fb267345b1 --- /dev/null +++ b/app/assets/images/intervention_participations/action-travel.svg @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/assets/javascripts/i18n/ext.coffee b/app/assets/javascripts/i18n/ext.coffee index 5d4269ba4e..925f62628a 100644 --- a/app/assets/javascripts/i18n/ext.coffee +++ b/app/assets/javascripts/i18n/ext.coffee @@ -95,6 +95,11 @@ time: -> return I18n.translate('time.formats.time') + full: -> + return I18n.translate('time.formats.full') + + fullJsFormat: -> + return I18n.translate('time.js_formats.full') I18nExt.ext = new I18nExt() diff --git a/app/assets/javascripts/i18n/translations.js b/app/assets/javascripts/i18n/translations.js index 72b62c8caa..be5c615491 100644 --- a/app/assets/javascripts/i18n/translations.js +++ b/app/assets/javascripts/i18n/translations.js @@ -1,10 +1,10 @@ I18n.translations || (I18n.translations = {}); -I18n.translations["arb"] = I18n.extend((I18n.translations["arb"] || {}), {"date":{"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names":["","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"formats":{"default":"%m/%d/%Y","legal":"%d %B %Y","long":"%B %d, %Y","month":"%B %Y","month_letter":"%d %B %Y","short":"%b %d","short_month":"%d/%Y"},"month_names":["","january","february","march","april","may","june","july","august","september","october","november","december"],"order":["month","day","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"انقر واسحب لرسم دائرة."}},"marker":{"tooltip":{"start":"انقر الخريطة لوضع علامة."}},"polygon":{"tooltip":{"cont":"انقر لمتابعة رسم الشكل.","end":"انقر النقطة الأولى لإغلاق هذا الشكل.","start":"انقر لبدء رسم الشكل."}},"polyline":{"error":"\u003cstrong\u003eخطأ:\u003c/strong\u003e حواف الشكل لا يمكن أن تعبر!","tooltip":{"cont":"انقر على مواصلة خط الرسم.","end":"انقر النقطة الأخيرة لإنهاء الخط.","start":"انقر لبدء رسم الخط."}},"rectangle":{"tooltip":{"start":"انقر واسحب لرسم مستطيل."}},"simpleshape":{"tooltip":{"end":"الماوس الإصدار لإنهاء الرسم."}}},"toolbar":{"actions":{"text":"إلغاء","title":"إلغاء الرسم"},"buttons":{"circle":"أرسم دائرة","marker":"رسم علامة","polygon":"رسم مضلع","polyline":"رسم شكل متعدد الخطوط","rectangle":"رسم مستطيل"},"undo":{"text":"حذف النقطة الأخيرة","title":"حذف النقطة الأخيرة رسمها"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"انقر فوق إلغاء الأمر للتراجع عن التغييرات.","text":"مقابض السحب، أو علامة لتحرير الميزة."}},"remove":{"tooltip":{"text":"انقر على ميزة لإزالة"}}},"toolbar":{"actions":{"cancel":{"text":"إلغاء","title":"إلغاء التحرير، ويتجاهل كل التغييرات."},"save":{"text":"حفظ","title":"حفظ التغيرات."}},"buttons":{"edit":"تحرير طبقات.","editDisabled":"عدم وجود طبقات لتحرير.","remove":"حذف طبقات.","removeDisabled":"لا طبقات حذف."}}},"fullscreenTitle":"تكبير الشاشة","importerButtonTitle":"استيراد","zoomInTitle":"تكبير","zoomOutTitle":"تصغير"}},"time":{"am":"صباحا","formats":{"compact":"٪ م /٪ د /٪ Y٪ H:٪ M","default":"%b. %d, %Y at %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"٪ B٪ د٪ Y٪ I:٪ M٪ ع"}}},"long":"%B %d, %Y %H:%M","short":"%d %b %H:%M","time":"%H:%M"},"pm":"مساءا"}}); -I18n.translations["cmn"] = I18n.extend((I18n.translations["cmn"] || {}), {"date":{"abbr_day_names":["周日","周一","周二","周三","周四","周五","周六"],"abbr_month_names":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"day_names":["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],"formats":{"default":"%Y-%m-%d","legal":"%d %B %Y","long":"%Y年%b%d日","month":"%B %Y","month_letter":"%d %B %Y","short":"%b%d日","short_month":"%m-%d"},"month_names":["","一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],"order":["year","month","day"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"单击并拖动绘制圆。"}},"marker":{"tooltip":{"start":"点击地图放置标记。"}},"polygon":{"tooltip":{"cont":"点击继续画形状。","end":"点击第一点,收这个形状。","start":"点击开始画的形状。"}},"polyline":{"error":"\u003cstrong\u003e错误:\u003c/strong\u003e形状边缘不能跨越!","tooltip":{"cont":"点击继续画线。","end":"点击最后一点到终点线。","start":"点击开始画线。"}},"rectangle":{"tooltip":{"start":"单击并拖动绘制矩形。"}},"simpleshape":{"tooltip":{"end":"释放鼠标完成绘制。"}}},"toolbar":{"actions":{"text":"取消","title":"取消绘图"},"buttons":{"circle":"画一个圆","marker":"画一个标记","polygon":"绘制多边形","polyline":"绘制折线","rectangle":"画一个矩形"},"undo":{"text":"删除最后一个点","title":"删除最后绘制点"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"单击取消撤消更改。","text":"拖动手柄,或标记编辑功能。"}},"remove":{"tooltip":{"text":"点击一个功能删除"}}},"toolbar":{"actions":{"cancel":{"text":"取消","title":"取消编辑,放弃所有更改。"},"save":{"text":"保存","title":"保存更改。"}},"buttons":{"edit":"编辑图层。","editDisabled":"没有图层编辑。","remove":"删除图层。","removeDisabled":"没有图层删除。"}}},"fullscreenTitle":"全屏","importerButtonTitle":"进口","zoomInTitle":"放大","zoomOutTitle":"缩小"}},"time":{"am":"上午","formats":{"compact":"%M /%D /%Y%H:%M","default":"%Y年%b%d日 %A %H:%M:%S %Z","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"%A%D,%Y%I:%M%P"}}},"long":"%Y年%b%d日 %H:%M","short":"%b%d日 %H:%M","time":"%H:%M"},"pm":"下午"}}); -I18n.translations["deu"] = I18n.extend((I18n.translations["deu"] || {}), {"date":{"abbr_day_names":["So","Mo","Di","Mi","Do","Fr","Sa"],"abbr_month_names":["","Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],"day_names":["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],"formats":{"default":"%d.%m.%Y","legal":"% D% B% Y","long":"%e. %B %Y","month":"%DURCH","month_letter":"% D% B% Y","short":"%e. %b","short_month":"%m.%Y"},"month_names":["","Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Klicken und Ziehen Kreis zu zeichnen."}},"marker":{"tooltip":{"start":"Klicken Sie Markierung auf der Karte zu platzieren."}},"polygon":{"tooltip":{"cont":"Klicken Sie auf Weiter Form zeichnen.","end":"Klicken Sie auf erste Punkt dieser Form zu schließen.","start":"Klicken Sie zum Starten der Formzeichnung."}},"polyline":{"error":"\u003cstrong\u003eFehler:\u003c/strong\u003e Form Kanten können nicht kreuzen!","tooltip":{"cont":"Klicken Sie auf Zeichnung Linie fortzusetzen.","end":"Klicken Sie auf den letzten Punkt-Linie zu beenden.","start":"Klicken Sie zeichnen Linie zu starten."}},"rectangle":{"tooltip":{"start":"Klicken und ziehen Rechteck zu zeichnen."}},"simpleshape":{"tooltip":{"end":"Lassen Sie die Maus zu beenden Zeichnung."}}},"toolbar":{"actions":{"text":"Stornieren","title":"Abbrechen Zeichnung"},"buttons":{"circle":"Zeichnen Sie einen Kreis","marker":"Zeichnen Sie einen Marker","polygon":"Zeichnen Sie ein Polygon","polyline":"Zeichnen Sie eine Polylinie","rectangle":"Zeichnen Sie ein Rechteck"},"undo":{"text":"Löschen letzte Punkt","title":"Löschen letzte Punkt gezogen"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Klicken Sie auf Abbrechen Änderungen rückgängig zu machen.","text":"Ziehen Griffe oder Marker-Funktion zu bearbeiten."}},"remove":{"tooltip":{"text":"Klicken Sie auf eine Funktion zu entfernen"}}},"toolbar":{"actions":{"cancel":{"text":"Stornieren","title":"Abbrechen Bearbeitung, werden alle Änderungen verworfen."},"save":{"text":"Sparen","title":"Änderungen speichern."}},"buttons":{"edit":"Bearbeiten Schichten.","editDisabled":"Keine Ebenen zu bearbeiten.","remove":"Löschen Schichten.","removeDisabled":"Keine Schichten zu löschen."}}},"fullscreenTitle":"Vollbild","importerButtonTitle":"Einführen","zoomInTitle":"Hineinzoomen","zoomOutTitle":"Rauszoomen"}},"time":{"am":"vormittags","formats":{"compact":"% M /% d /% Y% H:% M","default":"%A, %d. %B %Y, %H:%M Uhr","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"% B% d,% Y% H:% M% p"}}},"long":"%A, %d. %B %Y, %H:%M Uhr","short":"%d. %B, %H:%M Uhr","time":"%H:%M"},"pm":"nachmittags"}}); -I18n.translations["eng"] = I18n.extend((I18n.translations["eng"] || {}), {"date":{"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names":["","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"formats":{"default":"%m/%d/%Y","legal":"%d %B %Y","long":"%B %d, %Y","month":"%B %Y","month_letter":"%d %B %Y","short":"%b %d","short_month":"%m/%Y"},"month_names":["","january","february","march","april","may","june","july","august","september","october","november","december"],"order":["month","day","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Click and drag to draw circle."}},"marker":{"tooltip":{"start":"Click map to place marker."}},"polygon":{"tooltip":{"cont":"Click to continue drawing shape.","end":"Click first point to close this shape.","start":"Click to start drawing shape."}},"polyline":{"error":"\u003cstrong\u003eError:\u003c/strong\u003e shape edges cannot cross!","tooltip":{"cont":"Click to continue drawing line.","end":"Click last point to finish line.","start":"Click to start drawing line."}},"rectangle":{"tooltip":{"start":"Click and drag to draw rectangle."}},"simpleshape":{"tooltip":{"end":"Release mouse to finish drawing."}}},"toolbar":{"actions":{"text":"Cancel","title":"Cancel drawing"},"buttons":{"circle":"Draw a circle","marker":"Draw a marker","polygon":"Draw a polygon","polyline":"Draw a polyline","rectangle":"Draw a rectangle"},"undo":{"text":"Delete last point","title":"Delete last point drawn"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Click cancel to undo changes","text":"Drag handles, or marker to edit feature"}},"remove":{"tooltip":{"text":"Click on a feature to remove"}}},"toolbar":{"actions":{"cancel":{"text":"Cancel","title":"Cancel editing, discards all changes"},"save":{"text":"Save","title":"Save changes"}},"buttons":{"edit":"Edit layers","editDisabled":"No layers to edit","remove":"Delete layers","removeDisabled":"No layers to delete"}}},"fullscreenTitle":"Full Screen","importerButtonTitle":"Import","zoomInTitle":"Zoom in","zoomOutTitle":"Zoom out"}},"time":{"am":"am","formats":{"compact":"%m/%d/%Y %H:%M","default":"%b. %d, %Y at %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"%B %d, %Y %I:%M %p"}}},"long":"%B %d, %Y %H:%M","short":"%d %b %H:%M"},"pm":"pm"}}); -I18n.translations["fra"] = I18n.extend((I18n.translations["fra"] || {}), {"date":{"abbr_day_names":["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],"abbr_month_names":["","janv","févr","mars","avr","mai","juin","juil","août","sept","oct","nov","déc"],"day_names":["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],"formats":{"default":"%d/%m/%Y","legal":"%d %B %Y","long":"%A %d %B %Y","month":"%B %Y","month_letter":"%d %B %Y","short":"%d %b","short_month":"%m/%Y"},"month_names":["","janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Cliquez et déplacez pour dessiner un cercle."}},"marker":{"tooltip":{"start":"Cliquez sur la carte pour placer un marqueur."}},"polygon":{"tooltip":{"cont":"Cliquez pour continuer à dessiner une forme.","end":"Cliquez sur le dernier point pour fermer cette forme.","start":"Cliquez pour commencer à dessiner une forme."}},"polyline":{"error":"\u003cstrong\u003eErreur:\u003c/strong\u003e Les arrêtes de la forme ne doivent pas se croiser!","tooltip":{"cont":"Cliquez pour continuer à dessiner une ligne.","end":"Cliquez sur le dernier point pour terminer la ligne.","start":"Cliquez pour commencer à dessiner d’une ligne."}},"rectangle":{"tooltip":{"start":"Cliquez et déplacez pour dessiner un rectangle."}},"simpleshape":{"tooltip":{"end":"Relachez la souris pour finir de dessiner."}}},"toolbar":{"actions":{"text":"Annuler","title":"Annulez le dessin"},"buttons":{"circle":"Dessiner un cercle","marker":"Dessiner un marqueur","polygon":"Dessiner un polygone","polyline":"Dessiner une polyligne","rectangle":"Dessiner un rectangle"},"finish":{"text":"Terminer","title":"Terminer le dessin"},"undo":{"text":"Supprimer le dernier point","title":"Supprimer le dernier point déssiné"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Cliquez sur Annuler pour revenir sur les changements","text":"Déplacez les ancres, ou le marqueur pour éditer l’objet"}},"remove":{"tooltip":{"text":"Cliquez sur l’objet à enlever"}}},"toolbar":{"actions":{"cancel":{"text":"Annuler","title":"Annulez l’édition, ignorer tous les changements"},"save":{"text":"Sauver","title":"Sauvegardez les changements"}},"buttons":{"edit":"Editer les couches","editDisabled":"Pas de couches à éditer","remove":"Supprimer les couches","removeDisabled":"Pas de couches à supprimer"}}},"fullscreenTitle":"Plein écran","importerButtonTitle":"Importer","zoomInTitle":"Zoomer","zoomOutTitle":"Dézoomer"}},"time":{"am":"am","formats":{"compact":"%d/%m/%Y %H:%M","default":"%d/%m/%Y %H:%M","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"%d %B %Y %kh%M"}}},"long":"%A %d %B %Y à %H:%M","short":"%d %b %H:%M","time":"%H:%M"},"pm":"pm"}}); -I18n.translations["ita"] = I18n.extend((I18n.translations["ita"] || {}), {"date":{"abbr_day_names":["dom","lun","mar","mer","gio","ven","sab"],"abbr_month_names":["","gen","feb","mar","apr","mag","giu","lug","ago","set","ott","nov","dic"],"day_names":["domenica","lunedì","martedì","mercoledì","giovedì","venerdì","sabato"],"formats":{"default":"%d/%m/%Y","legal":"% D% B% Y","long":"%d %B %Y","month":"% B% Y","month_letter":"% D% B% Y","short":"%d %b","short_month":"%m/%Y"},"month_names":["","gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Fare clic e trascinare per disegnare cerchio."}},"marker":{"tooltip":{"start":"Clicca sulla mappa per posizionare marker."}},"polygon":{"tooltip":{"cont":"Clicca per continuare a disegnare la forma.","end":"Clicca primo punto per chiudere questa forma.","start":"Fare clic per iniziare a disegnare la forma."}},"polyline":{"error":"\u003cstrong\u003eErrore:\u003c/strong\u003e bordi di forma non possono attraversare!","tooltip":{"cont":"Clicca qui per continuare la linea di disegno.","end":"Clicca ultimo punto al traguardo.","start":"Fare clic per avviare la linea di disegno."}},"rectangle":{"tooltip":{"start":"Fare clic e trascinare per disegnare rettangolo."}},"simpleshape":{"tooltip":{"end":"Il mouse di rilascio per terminare il disegno."}}},"toolbar":{"actions":{"text":"Annulla","title":"Annulla disegno"},"buttons":{"circle":"Disegnare un cerchio","marker":"Disegnare un marker","polygon":"Disegnare un poligono","polyline":"Disegnare una polilinea","rectangle":"Disegnare un rettangolo"},"undo":{"text":"Cancellare l'ultimo punto","title":"Cancellare l'ultimo punto disegnato"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Scegliere Annulla per annullare le modifiche.","text":"Maniglie di trascinamento, o marcatore di Modifica funzione."}},"remove":{"tooltip":{"text":"Fare clic su una funzione per rimuovere"}}},"toolbar":{"actions":{"cancel":{"text":"Annulla","title":"Annullare la modifica, scarta tutte le modifiche."},"save":{"text":"Salvare","title":"Salva I Cambiamenti."}},"buttons":{"edit":"Modificare i livelli.","editDisabled":"Non ci sono strati di modificare.","remove":"Eliminare i livelli.","removeDisabled":"Non ci sono livelli da eliminare."}}},"fullscreenTitle":"A schermo intero","importerButtonTitle":"Importare","zoomInTitle":"Ingrandire","zoomOutTitle":"Zoom indietro"}},"time":{"am":"am","formats":{"compact":"% M /% d /% Y% H:% M","default":"%a %d %b %Y, %H:%M:%S %z","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"% B% d,% Y% H:% M% p"}}},"long":"%d %B %Y %H:%M","short":"%d %b %H:%M","time":"%H:%M"},"pm":"pm"}}); -I18n.translations["jpn"] = I18n.extend((I18n.translations["jpn"] || {}), {"date":{"abbr_day_names":["日","月","火","水","木","金","土"],"abbr_month_names":["","一","二","三","四","五","六","七","八","九","十","十一","十二"],"day_names":["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"],"formats":{"default":"%Y/%m/%d","legal":"%d %B %Y","long":"%Y年%m月%d日(%a)","month":"%Y年%m月","month_letter":"%d %B %Y","short":"%m/%d","short_month":"%m/%d"},"month_names":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"order":["month","day","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"クリックして、円を描くようにドラッグします。"}},"marker":{"tooltip":{"start":"マーカーを配置するには、地図をクリックしてください。"}},"polygon":{"tooltip":{"cont":"形状の描画をクリックして続行します。","end":"この形状を閉じるには、最初のポイントをクリックしてください。","start":"形状を描画を開始する場合にクリックします。"}},"polyline":{"error":"\u003cstrong\u003eエラー:\u003c/strong\u003e形状のエッジが交差することはできません!","tooltip":{"cont":"描画ラインをクリックして続行します。","end":"行を終了する最後のポイントをクリックしてください。","start":"ラインを描画を開始する場合にクリックします。"}},"rectangle":{"tooltip":{"start":"四角形を描画するためにクリックしてドラッグします。"}},"simpleshape":{"tooltip":{"end":"描画を終了するには、マウスを離します。"}}},"toolbar":{"actions":{"text":"キャンセル","title":"図面をキャンセル"},"buttons":{"circle":"円を描きます","marker":"マーカーを引きます","polygon":"ポリゴンを描画","polyline":"ポリラインを描きます","rectangle":"四角形を描画"},"undo":{"text":"最後のポイントを削除します。","title":"描かれた最後のポイントを削除します。"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"変更を元に戻すには、[キャンセル]をクリックします。","text":"機能を編集するには、ハンドル、またはマーカーをドラッグします。"}},"remove":{"tooltip":{"text":"削除する機能をクリックしてください"}}},"toolbar":{"actions":{"cancel":{"text":"キャンセル","title":"編集をキャンセルし、すべての変更を破棄します。"},"save":{"text":"セーブ","title":"変更内容を保存。"}},"buttons":{"edit":"編集層。","editDisabled":"編集する層いいえ。","remove":"レイヤーを削除します。","removeDisabled":"削除するレイヤーいいえ。"}}},"fullscreenTitle":"全画面表示","importerButtonTitle":"インポート","zoomInTitle":"ズームイン","zoomOutTitle":"ズームアウトする"}},"time":{"am":"午前","formats":{"compact":"%のM /%D /%Y%のH:%M","default":"%Y/%m/%d %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"%のB%dの、%Yの%I:%Mを%P"}}},"long":"%Y年%m月%d日(%a) %H時%M分%S秒 %z","short":"%y/%m/%d %H:%M","time":"%H:%M"},"pm":"午後"}}); -I18n.translations["por"] = I18n.extend((I18n.translations["por"] || {}), {"date":{"abbr_day_names":["Dom","Seg","Ter","Qua","Qui","Sex","Sab"],"abbr_month_names":["","jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],"day_names":["Domingo","Segunda","Terça","Quarta","Quinta","Sexta","Sabádo"],"formats":{"default":"%d/%m/%Y","legal":"%d %B %Y","long":"%d de %B de %Y","month":"%B %Y","month_letter":"%d %B %Y","short":"%d %b","short_month":"%m/%Y"},"month_names":["","janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Clique e arraste para desenhar círculo."}},"marker":{"tooltip":{"start":"Clique no mapa para colocar marcador."}},"polygon":{"tooltip":{"cont":"Clique para continuar a desenhar a forma.","end":"Clique primeiro ponto para fechar esta forma.","start":"Clique para começar a desenhar a forma."}},"polyline":{"error":"\u003cstrong\u003eErro:\u003c/strong\u003e forma bordas não pode cruzar!","tooltip":{"cont":"Clique para continuar a linha de desenho.","end":"Clique último ponto para terminar linha.","start":"Clique para iniciar a linha de desenho."}},"rectangle":{"tooltip":{"start":"Clique e arraste para desenhar um retângulo."}},"simpleshape":{"tooltip":{"end":"Rato de liberação para finalizar o desenho."}}},"toolbar":{"actions":{"text":"Cancelar","title":"Anular desenho"},"buttons":{"circle":"Desenhar um círculo","marker":"Desenhe um marcador","polygon":"Desenhar um polígono","polyline":"Desenhar um polígono","rectangle":"Desenhe um retângulo"},"undo":{"text":"Excluir último ponto","title":"Excluir último ponto desenhado"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Cancele para desfazer as alterações.","text":"Alças de arrasto, ou marcador para editar recurso."}},"remove":{"tooltip":{"text":"Clique em um recurso para remover"}}},"toolbar":{"actions":{"cancel":{"text":"Cancelar","title":"Cancelar a edição, descarta todas as alterações."},"save":{"text":"Salvar","title":"Salvar alterações."}},"buttons":{"edit":"Editar camadas.","editDisabled":"Não há camadas para editar.","remove":"Excluir camadas.","removeDisabled":"Nenhuma camada excluir."}}},"fullscreenTitle":"Tela cheia","importerButtonTitle":"Importar","zoomInTitle":"Mais Zoom","zoomOutTitle":"Zoom out"}},"time":{"am":"am","formats":{"compact":"% M /% d /% Y% H:% M","default":"%a, %d de %B de %Y, %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"% B% d,% Y% I:% M% p"}}},"long":"%d de %B de %Y, %H:%M","short":"%d de %B, %H:%M","time":"%H:%M"},"pm":"pm"}}); -I18n.translations["spa"] = I18n.extend((I18n.translations["spa"] || {}), {"date":{"abbr_day_names":["Do","Lu","Ma","Mi","Ju","Vi","Sá"],"abbr_month_names":["","ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],"day_names":["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"],"formats":{"default":"%d/%m/%Y","legal":"%d %B %Y","long":"%B %d, %Y","month":"% B% Y","month_letter":"%d %B %Y","short":"%b %d","short_month":"%m/%Y"},"month_names":["","enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Haga clic y arrastre para dibujar el círculo."}},"marker":{"tooltip":{"start":"Haga clic en el mapa para colocar el marcador."}},"polygon":{"tooltip":{"cont":"Haga clic para continuar el dibujo de la forma.","end":"Haga clic en el primer punto para cerrar esta forma.","start":"Haga clic para empezar a dibujar la forma."}},"polyline":{"error":"\u003cstrong\u003eError:\u003c/strong\u003e bordes de la forma no pueden cruzar!","tooltip":{"cont":"Clic para continuar la línea de dibujo.","end":"Haga clic último punto de la línea de meta.","start":"Haga clic para iniciar la línea de dibujo."}},"rectangle":{"tooltip":{"start":"Haga clic y arrastre para dibujar un rectángulo."}},"simpleshape":{"tooltip":{"end":"Ratón de liberación para terminar de dibujar."}}},"toolbar":{"actions":{"text":"Cancelar","title":"Cancelar dibujo"},"buttons":{"circle":"Dibuja un circulo","marker":"Dibuje un marcador","polygon":"Dibujar un polígono","polyline":"Dibuje una polilínea","rectangle":"Dibujar un rectángulo"},"undo":{"text":"Eliminar último punto","title":"Eliminar último punto dibujado"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Haga clic en Cancelar para deshacer los cambios.","text":"Control de arrastre, o marcador para editar función."}},"remove":{"tooltip":{"text":"Haga clic en una función para eliminar"}}},"toolbar":{"actions":{"cancel":{"text":"Cancelar","title":"Cancelar la edición, descarta todos los cambios."},"save":{"text":"Salvar","title":"Guardar cambios."}},"buttons":{"edit":"Editar las capas.","editDisabled":"No hay capas para editar.","remove":"Eliminar capas.","removeDisabled":"No hay capas que desea eliminar."}}},"fullscreenTitle":"Pantalla completa","importerButtonTitle":"Importar","zoomInTitle":"Acercarse","zoomOutTitle":"Disminuir el zoom"}},"time":{"am":"am","formats":{"compact":"% M /% d /% Y% H:% M","default":"%d %b. %Y - %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"% B% d,% Y% I:% M% p"}}},"long":"%B %d, %Y %H:%M","short":"%d %b %H:%M","time":"%H:%M"},"pm":"pm"}}); +I18n.translations["arb"] = I18n.extend((I18n.translations["arb"] || {}), {"date":{"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names":["","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"formats":{"default":"%m/%d/%Y","legal":"%d %B %Y","long":"%B %d, %Y","month":"%B %Y","month_letter":"%d %B %Y","short":"%b %d","short_month":"%d/%Y"},"month_names":["","january","february","march","april","may","june","july","august","september","october","november","december"],"order":["month","day","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"انقر واسحب لرسم دائرة."}},"marker":{"tooltip":{"start":"انقر الخريطة لوضع علامة."}},"polygon":{"tooltip":{"cont":"انقر لمتابعة رسم الشكل.","end":"انقر النقطة الأولى لإغلاق هذا الشكل.","start":"انقر لبدء رسم الشكل."}},"polyline":{"error":"\u003cstrong\u003eخطأ:\u003c/strong\u003e حواف الشكل لا يمكن أن تعبر!","tooltip":{"cont":"انقر على مواصلة خط الرسم.","end":"انقر النقطة الأخيرة لإنهاء الخط.","start":"انقر لبدء رسم الخط."}},"rectangle":{"tooltip":{"start":"انقر واسحب لرسم مستطيل."}},"simpleshape":{"tooltip":{"end":"الماوس الإصدار لإنهاء الرسم."}}},"toolbar":{"actions":{"text":"إلغاء","title":"إلغاء الرسم"},"buttons":{"circle":"أرسم دائرة","marker":"رسم علامة","polygon":"رسم مضلع","polyline":"رسم شكل متعدد الخطوط","rectangle":"رسم مستطيل"},"undo":{"text":"حذف النقطة الأخيرة","title":"حذف النقطة الأخيرة رسمها"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"انقر فوق إلغاء الأمر للتراجع عن التغييرات.","text":"مقابض السحب، أو علامة لتحرير الميزة."}},"remove":{"tooltip":{"text":"انقر على ميزة لإزالة"}}},"toolbar":{"actions":{"cancel":{"text":"إلغاء","title":"إلغاء التحرير، ويتجاهل كل التغييرات."},"save":{"text":"حفظ","title":"حفظ التغيرات."}},"buttons":{"edit":"تحرير طبقات.","editDisabled":"عدم وجود طبقات لتحرير.","remove":"حذف طبقات.","removeDisabled":"لا طبقات حذف."}}},"fullscreenTitle":"تكبير الشاشة","importerButtonTitle":"استيراد","zoomInTitle":"تكبير","zoomOutTitle":"تصغير"}},"time":{"am":"صباحا","formats":{"compact":"٪ م /٪ د /٪ Y٪ H:٪ M","default":"%b. %d, %Y at %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"٪ B٪ د٪ Y٪ I:٪ M٪ ع"}}},"full":"%m/%d/%Y %H:%M:%S","long":"%B %d, %Y %H:%M","short":"%d %b %H:%M","time":"%H:%M"},"js_formats":{"compact":"MM/DD/YYYY HH:mm","full":"MM/DD/YYYY HH:mm:ss"},"pm":"مساءا"}}); +I18n.translations["cmn"] = I18n.extend((I18n.translations["cmn"] || {}), {"date":{"abbr_day_names":["周日","周一","周二","周三","周四","周五","周六"],"abbr_month_names":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"day_names":["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],"formats":{"default":"%Y-%m-%d","legal":"%d %B %Y","long":"%Y年%b%d日","month":"%B %Y","month_letter":"%d %B %Y","short":"%b%d日","short_month":"%m-%d"},"month_names":["","一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],"order":["year","month","day"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"单击并拖动绘制圆。"}},"marker":{"tooltip":{"start":"点击地图放置标记。"}},"polygon":{"tooltip":{"cont":"点击继续画形状。","end":"点击第一点,收这个形状。","start":"点击开始画的形状。"}},"polyline":{"error":"\u003cstrong\u003e错误:\u003c/strong\u003e形状边缘不能跨越!","tooltip":{"cont":"点击继续画线。","end":"点击最后一点到终点线。","start":"点击开始画线。"}},"rectangle":{"tooltip":{"start":"单击并拖动绘制矩形。"}},"simpleshape":{"tooltip":{"end":"释放鼠标完成绘制。"}}},"toolbar":{"actions":{"text":"取消","title":"取消绘图"},"buttons":{"circle":"画一个圆","marker":"画一个标记","polygon":"绘制多边形","polyline":"绘制折线","rectangle":"画一个矩形"},"undo":{"text":"删除最后一个点","title":"删除最后绘制点"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"单击取消撤消更改。","text":"拖动手柄,或标记编辑功能。"}},"remove":{"tooltip":{"text":"点击一个功能删除"}}},"toolbar":{"actions":{"cancel":{"text":"取消","title":"取消编辑,放弃所有更改。"},"save":{"text":"保存","title":"保存更改。"}},"buttons":{"edit":"编辑图层。","editDisabled":"没有图层编辑。","remove":"删除图层。","removeDisabled":"没有图层删除。"}}},"fullscreenTitle":"全屏","importerButtonTitle":"进口","zoomInTitle":"放大","zoomOutTitle":"缩小"}},"time":{"am":"上午","formats":{"compact":"%M /%D /%Y%H:%M","default":"%Y年%b%d日 %A %H:%M:%S %Z","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"%A%D,%Y%I:%M%P"}}},"full":"%m/%d/%Y %H:%M:%S","long":"%Y年%b%d日 %H:%M","short":"%b%d日 %H:%M","time":"%H:%M"},"js_formats":{"compact":"MM/DD/YYYY HH:mm","full":"MM/DD/YYYY HH:mm:ss"},"pm":"下午"}}); +I18n.translations["deu"] = I18n.extend((I18n.translations["deu"] || {}), {"date":{"abbr_day_names":["So","Mo","Di","Mi","Do","Fr","Sa"],"abbr_month_names":["","Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],"day_names":["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],"formats":{"default":"%d.%m.%Y","legal":"% D% B% Y","long":"%e. %B %Y","month":"%DURCH","month_letter":"% D% B% Y","short":"%e. %b","short_month":"%m.%Y"},"month_names":["","Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Klicken und Ziehen Kreis zu zeichnen."}},"marker":{"tooltip":{"start":"Klicken Sie Markierung auf der Karte zu platzieren."}},"polygon":{"tooltip":{"cont":"Klicken Sie auf Weiter Form zeichnen.","end":"Klicken Sie auf erste Punkt dieser Form zu schließen.","start":"Klicken Sie zum Starten der Formzeichnung."}},"polyline":{"error":"\u003cstrong\u003eFehler:\u003c/strong\u003e Form Kanten können nicht kreuzen!","tooltip":{"cont":"Klicken Sie auf Zeichnung Linie fortzusetzen.","end":"Klicken Sie auf den letzten Punkt-Linie zu beenden.","start":"Klicken Sie zeichnen Linie zu starten."}},"rectangle":{"tooltip":{"start":"Klicken und ziehen Rechteck zu zeichnen."}},"simpleshape":{"tooltip":{"end":"Lassen Sie die Maus zu beenden Zeichnung."}}},"toolbar":{"actions":{"text":"Stornieren","title":"Abbrechen Zeichnung"},"buttons":{"circle":"Zeichnen Sie einen Kreis","marker":"Zeichnen Sie einen Marker","polygon":"Zeichnen Sie ein Polygon","polyline":"Zeichnen Sie eine Polylinie","rectangle":"Zeichnen Sie ein Rechteck"},"undo":{"text":"Löschen letzte Punkt","title":"Löschen letzte Punkt gezogen"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Klicken Sie auf Abbrechen Änderungen rückgängig zu machen.","text":"Ziehen Griffe oder Marker-Funktion zu bearbeiten."}},"remove":{"tooltip":{"text":"Klicken Sie auf eine Funktion zu entfernen"}}},"toolbar":{"actions":{"cancel":{"text":"Stornieren","title":"Abbrechen Bearbeitung, werden alle Änderungen verworfen."},"save":{"text":"Sparen","title":"Änderungen speichern."}},"buttons":{"edit":"Bearbeiten Schichten.","editDisabled":"Keine Ebenen zu bearbeiten.","remove":"Löschen Schichten.","removeDisabled":"Keine Schichten zu löschen."}}},"fullscreenTitle":"Vollbild","importerButtonTitle":"Einführen","zoomInTitle":"Hineinzoomen","zoomOutTitle":"Rauszoomen"}},"time":{"am":"vormittags","formats":{"compact":"% M /% d /% Y% H:% M","default":"%A, %d. %B %Y, %H:%M Uhr","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"% B% d,% Y% H:% M% p"}}},"full":"%m/%d/%Y %H:%M:%S","long":"%A, %d. %B %Y, %H:%M Uhr","short":"%d. %B, %H:%M Uhr","time":"%H:%M"},"js_formats":{"compact":"MM/DD/YYYY HH:mm","full":"MM/DD/YYYY HH:mm:ss"},"pm":"nachmittags"}}); +I18n.translations["eng"] = I18n.extend((I18n.translations["eng"] || {}), {"date":{"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names":["","jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"formats":{"default":"%m/%d/%Y","legal":"%d %B %Y","long":"%B %d, %Y","month":"%B %Y","month_letter":"%d %B %Y","short":"%b %d","short_month":"%m/%Y"},"month_names":["","january","february","march","april","may","june","july","august","september","october","november","december"],"order":["month","day","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Click and drag to draw circle."}},"marker":{"tooltip":{"start":"Click map to place marker."}},"polygon":{"tooltip":{"cont":"Click to continue drawing shape.","end":"Click first point to close this shape.","start":"Click to start drawing shape."}},"polyline":{"error":"\u003cstrong\u003eError:\u003c/strong\u003e shape edges cannot cross!","tooltip":{"cont":"Click to continue drawing line.","end":"Click last point to finish line.","start":"Click to start drawing line."}},"rectangle":{"tooltip":{"start":"Click and drag to draw rectangle."}},"simpleshape":{"tooltip":{"end":"Release mouse to finish drawing."}}},"toolbar":{"actions":{"text":"Cancel","title":"Cancel drawing"},"buttons":{"circle":"Draw a circle","marker":"Draw a marker","polygon":"Draw a polygon","polyline":"Draw a polyline","rectangle":"Draw a rectangle"},"undo":{"text":"Delete last point","title":"Delete last point drawn"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Click cancel to undo changes","text":"Drag handles, or marker to edit feature"}},"remove":{"tooltip":{"text":"Click on a feature to remove"}}},"toolbar":{"actions":{"cancel":{"text":"Cancel","title":"Cancel editing, discards all changes"},"save":{"text":"Save","title":"Save changes"}},"buttons":{"edit":"Edit layers","editDisabled":"No layers to edit","remove":"Delete layers","removeDisabled":"No layers to delete"}}},"fullscreenTitle":"Full Screen","importerButtonTitle":"Import","zoomInTitle":"Zoom in","zoomOutTitle":"Zoom out"}},"time":{"am":"am","formats":{"compact":"%m/%d/%Y %H:%M","default":"%b. %d, %Y at %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"%B %d, %Y %I:%M %p"}}},"full":"%m/%d/%Y %H:%M:%S","long":"%B %d, %Y %H:%M","short":"%d %b %H:%M"},"js_formats":{"compact":"MM/DD/YYYY HH:mm","full":"MM/DD/YYYY HH:mm:ss"},"pm":"pm"}}); +I18n.translations["fra"] = I18n.extend((I18n.translations["fra"] || {}), {"date":{"abbr_day_names":["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],"abbr_month_names":["","janv","févr","mars","avr","mai","juin","juil","août","sept","oct","nov","déc"],"day_names":["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],"formats":{"default":"%d/%m/%Y","legal":"%d %B %Y","long":"%A %d %B %Y","month":"%B %Y","month_letter":"%d %B %Y","short":"%d %b","short_month":"%m/%Y"},"month_names":["","janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Cliquez et déplacez pour dessiner un cercle."}},"marker":{"tooltip":{"start":"Cliquez sur la carte pour placer un marqueur."}},"polygon":{"tooltip":{"cont":"Cliquez pour continuer à dessiner une forme.","end":"Cliquez sur le dernier point pour fermer cette forme.","start":"Cliquez pour commencer à dessiner une forme."}},"polyline":{"error":"\u003cstrong\u003eErreur:\u003c/strong\u003e Les arrêtes de la forme ne doivent pas se croiser!","tooltip":{"cont":"Cliquez pour continuer à dessiner une ligne.","end":"Cliquez sur le dernier point pour terminer la ligne.","start":"Cliquez pour commencer à dessiner d’une ligne."}},"rectangle":{"tooltip":{"start":"Cliquez et déplacez pour dessiner un rectangle."}},"simpleshape":{"tooltip":{"end":"Relachez la souris pour finir de dessiner."}}},"toolbar":{"actions":{"text":"Annuler","title":"Annulez le dessin"},"buttons":{"circle":"Dessiner un cercle","marker":"Dessiner un marqueur","polygon":"Dessiner un polygone","polyline":"Dessiner une polyligne","rectangle":"Dessiner un rectangle"},"finish":{"text":"Terminer","title":"Terminer le dessin"},"undo":{"text":"Supprimer le dernier point","title":"Supprimer le dernier point déssiné"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Cliquez sur Annuler pour revenir sur les changements","text":"Déplacez les ancres, ou le marqueur pour éditer l’objet"}},"remove":{"tooltip":{"text":"Cliquez sur l’objet à enlever"}}},"toolbar":{"actions":{"cancel":{"text":"Annuler","title":"Annulez l’édition, ignorer tous les changements"},"save":{"text":"Sauver","title":"Sauvegardez les changements"}},"buttons":{"edit":"Editer les couches","editDisabled":"Pas de couches à éditer","remove":"Supprimer les couches","removeDisabled":"Pas de couches à supprimer"}}},"fullscreenTitle":"Plein écran","importerButtonTitle":"Importer","zoomInTitle":"Zoomer","zoomOutTitle":"Dézoomer"}},"time":{"am":"am","formats":{"compact":"%d/%m/%Y %H:%M","default":"%d/%m/%Y %H:%M","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"%d %B %Y %kh%M"}}},"full":"%d/%m/%Y %H:%M:%S","long":"%A %d %B %Y à %H:%M","short":"%d %b %H:%M","time":"%H:%M"},"js_formats":{"compact":"DD/MM/YYYY HH:mm","full":"DD/MM/YYYY HH:mm:ss"},"pm":"pm"}}); +I18n.translations["ita"] = I18n.extend((I18n.translations["ita"] || {}), {"date":{"abbr_day_names":["dom","lun","mar","mer","gio","ven","sab"],"abbr_month_names":["","gen","feb","mar","apr","mag","giu","lug","ago","set","ott","nov","dic"],"day_names":["domenica","lunedì","martedì","mercoledì","giovedì","venerdì","sabato"],"formats":{"default":"%d/%m/%Y","legal":"% D% B% Y","long":"%d %B %Y","month":"% B% Y","month_letter":"% D% B% Y","short":"%d %b","short_month":"%m/%Y"},"month_names":["","gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Fare clic e trascinare per disegnare cerchio."}},"marker":{"tooltip":{"start":"Clicca sulla mappa per posizionare marker."}},"polygon":{"tooltip":{"cont":"Clicca per continuare a disegnare la forma.","end":"Clicca primo punto per chiudere questa forma.","start":"Fare clic per iniziare a disegnare la forma."}},"polyline":{"error":"\u003cstrong\u003eErrore:\u003c/strong\u003e bordi di forma non possono attraversare!","tooltip":{"cont":"Clicca qui per continuare la linea di disegno.","end":"Clicca ultimo punto al traguardo.","start":"Fare clic per avviare la linea di disegno."}},"rectangle":{"tooltip":{"start":"Fare clic e trascinare per disegnare rettangolo."}},"simpleshape":{"tooltip":{"end":"Il mouse di rilascio per terminare il disegno."}}},"toolbar":{"actions":{"text":"Annulla","title":"Annulla disegno"},"buttons":{"circle":"Disegnare un cerchio","marker":"Disegnare un marker","polygon":"Disegnare un poligono","polyline":"Disegnare una polilinea","rectangle":"Disegnare un rettangolo"},"undo":{"text":"Cancellare l'ultimo punto","title":"Cancellare l'ultimo punto disegnato"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Scegliere Annulla per annullare le modifiche.","text":"Maniglie di trascinamento, o marcatore di Modifica funzione."}},"remove":{"tooltip":{"text":"Fare clic su una funzione per rimuovere"}}},"toolbar":{"actions":{"cancel":{"text":"Annulla","title":"Annullare la modifica, scarta tutte le modifiche."},"save":{"text":"Salvare","title":"Salva I Cambiamenti."}},"buttons":{"edit":"Modificare i livelli.","editDisabled":"Non ci sono strati di modificare.","remove":"Eliminare i livelli.","removeDisabled":"Non ci sono livelli da eliminare."}}},"fullscreenTitle":"A schermo intero","importerButtonTitle":"Importare","zoomInTitle":"Ingrandire","zoomOutTitle":"Zoom indietro"}},"time":{"am":"am","formats":{"compact":"% M /% d /% Y% H:% M","default":"%a %d %b %Y, %H:%M:%S %z","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"% B% d,% Y% H:% M% p"}}},"full":"%m/%d/%Y %H:%M:%S","long":"%d %B %Y %H:%M","short":"%d %b %H:%M","time":"%H:%M"},"js_formats":{"compact":"MM/DD/YYYY HH:mm","full":"MM/DD/YYYY HH:mm:ss"},"pm":"pm"}}); +I18n.translations["jpn"] = I18n.extend((I18n.translations["jpn"] || {}), {"date":{"abbr_day_names":["日","月","火","水","木","金","土"],"abbr_month_names":["","一","二","三","四","五","六","七","八","九","十","十一","十二"],"day_names":["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"],"formats":{"default":"%Y/%m/%d","legal":"%d %B %Y","long":"%Y年%m月%d日(%a)","month":"%Y年%m月","month_letter":"%d %B %Y","short":"%m/%d","short_month":"%m/%d"},"month_names":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"order":["month","day","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"クリックして、円を描くようにドラッグします。"}},"marker":{"tooltip":{"start":"マーカーを配置するには、地図をクリックしてください。"}},"polygon":{"tooltip":{"cont":"形状の描画をクリックして続行します。","end":"この形状を閉じるには、最初のポイントをクリックしてください。","start":"形状を描画を開始する場合にクリックします。"}},"polyline":{"error":"\u003cstrong\u003eエラー:\u003c/strong\u003e形状のエッジが交差することはできません!","tooltip":{"cont":"描画ラインをクリックして続行します。","end":"行を終了する最後のポイントをクリックしてください。","start":"ラインを描画を開始する場合にクリックします。"}},"rectangle":{"tooltip":{"start":"四角形を描画するためにクリックしてドラッグします。"}},"simpleshape":{"tooltip":{"end":"描画を終了するには、マウスを離します。"}}},"toolbar":{"actions":{"text":"キャンセル","title":"図面をキャンセル"},"buttons":{"circle":"円を描きます","marker":"マーカーを引きます","polygon":"ポリゴンを描画","polyline":"ポリラインを描きます","rectangle":"四角形を描画"},"undo":{"text":"最後のポイントを削除します。","title":"描かれた最後のポイントを削除します。"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"変更を元に戻すには、[キャンセル]をクリックします。","text":"機能を編集するには、ハンドル、またはマーカーをドラッグします。"}},"remove":{"tooltip":{"text":"削除する機能をクリックしてください"}}},"toolbar":{"actions":{"cancel":{"text":"キャンセル","title":"編集をキャンセルし、すべての変更を破棄します。"},"save":{"text":"セーブ","title":"変更内容を保存。"}},"buttons":{"edit":"編集層。","editDisabled":"編集する層いいえ。","remove":"レイヤーを削除します。","removeDisabled":"削除するレイヤーいいえ。"}}},"fullscreenTitle":"全画面表示","importerButtonTitle":"インポート","zoomInTitle":"ズームイン","zoomOutTitle":"ズームアウトする"}},"time":{"am":"午前","formats":{"compact":"%のM /%D /%Y%のH:%M","default":"%Y/%m/%d %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"%のB%dの、%Yの%I:%Mを%P"}}},"full":"%m/%d/%Y %H:%M:%S","long":"%Y年%m月%d日(%a) %H時%M分%S秒 %z","short":"%y/%m/%d %H:%M","time":"%H:%M"},"js_formats":{"compact":"MM/DD/YYYY HH:mm","full":"MM/DD/YYYY HH:mm:ss"},"pm":"午後"}}); +I18n.translations["por"] = I18n.extend((I18n.translations["por"] || {}), {"date":{"abbr_day_names":["Dom","Seg","Ter","Qua","Qui","Sex","Sab"],"abbr_month_names":["","jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],"day_names":["Domingo","Segunda","Terça","Quarta","Quinta","Sexta","Sabádo"],"formats":{"default":"%d/%m/%Y","legal":"%d %B %Y","long":"%d de %B de %Y","month":"%B %Y","month_letter":"%d %B %Y","short":"%d %b","short_month":"%m/%Y"},"month_names":["","janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Clique e arraste para desenhar círculo."}},"marker":{"tooltip":{"start":"Clique no mapa para colocar marcador."}},"polygon":{"tooltip":{"cont":"Clique para continuar a desenhar a forma.","end":"Clique primeiro ponto para fechar esta forma.","start":"Clique para começar a desenhar a forma."}},"polyline":{"error":"\u003cstrong\u003eErro:\u003c/strong\u003e forma bordas não pode cruzar!","tooltip":{"cont":"Clique para continuar a linha de desenho.","end":"Clique último ponto para terminar linha.","start":"Clique para iniciar a linha de desenho."}},"rectangle":{"tooltip":{"start":"Clique e arraste para desenhar um retângulo."}},"simpleshape":{"tooltip":{"end":"Rato de liberação para finalizar o desenho."}}},"toolbar":{"actions":{"text":"Cancelar","title":"Anular desenho"},"buttons":{"circle":"Desenhar um círculo","marker":"Desenhe um marcador","polygon":"Desenhar um polígono","polyline":"Desenhar um polígono","rectangle":"Desenhe um retângulo"},"undo":{"text":"Excluir último ponto","title":"Excluir último ponto desenhado"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Cancele para desfazer as alterações.","text":"Alças de arrasto, ou marcador para editar recurso."}},"remove":{"tooltip":{"text":"Clique em um recurso para remover"}}},"toolbar":{"actions":{"cancel":{"text":"Cancelar","title":"Cancelar a edição, descarta todas as alterações."},"save":{"text":"Salvar","title":"Salvar alterações."}},"buttons":{"edit":"Editar camadas.","editDisabled":"Não há camadas para editar.","remove":"Excluir camadas.","removeDisabled":"Nenhuma camada excluir."}}},"fullscreenTitle":"Tela cheia","importerButtonTitle":"Importar","zoomInTitle":"Mais Zoom","zoomOutTitle":"Zoom out"}},"time":{"am":"am","formats":{"compact":"% M /% d /% Y% H:% M","default":"%a, %d de %B de %Y, %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"% B% d,% Y% I:% M% p"}}},"full":"%m/%d/%Y %H:%M:%S","long":"%d de %B de %Y, %H:%M","short":"%d de %B, %H:%M","time":"%H:%M"},"js_formats":{"compact":"MM/DD/YYYY HH:mm","full":"MM/DD/YYYY HH:mm:ss"},"pm":"pm"}}); +I18n.translations["spa"] = I18n.extend((I18n.translations["spa"] || {}), {"date":{"abbr_day_names":["Do","Lu","Ma","Mi","Ju","Vi","Sá"],"abbr_month_names":["","ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],"day_names":["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"],"formats":{"default":"%d/%m/%Y","legal":"%d %B %Y","long":"%B %d, %Y","month":"% B% Y","month_letter":"%d %B %Y","short":"%b %d","short_month":"%m/%Y"},"month_names":["","enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],"order":["day","month","year"]},"front-end":{"leaflet":{"draw":{"handlers":{"circle":{"tooltip":{"start":"Haga clic y arrastre para dibujar el círculo."}},"marker":{"tooltip":{"start":"Haga clic en el mapa para colocar el marcador."}},"polygon":{"tooltip":{"cont":"Haga clic para continuar el dibujo de la forma.","end":"Haga clic en el primer punto para cerrar esta forma.","start":"Haga clic para empezar a dibujar la forma."}},"polyline":{"error":"\u003cstrong\u003eError:\u003c/strong\u003e bordes de la forma no pueden cruzar!","tooltip":{"cont":"Clic para continuar la línea de dibujo.","end":"Haga clic último punto de la línea de meta.","start":"Haga clic para iniciar la línea de dibujo."}},"rectangle":{"tooltip":{"start":"Haga clic y arrastre para dibujar un rectángulo."}},"simpleshape":{"tooltip":{"end":"Ratón de liberación para terminar de dibujar."}}},"toolbar":{"actions":{"text":"Cancelar","title":"Cancelar dibujo"},"buttons":{"circle":"Dibuja un circulo","marker":"Dibuje un marcador","polygon":"Dibujar un polígono","polyline":"Dibuje una polilínea","rectangle":"Dibujar un rectángulo"},"undo":{"text":"Eliminar último punto","title":"Eliminar último punto dibujado"}}},"edit":{"handlers":{"edit":{"tooltip":{"subtext":"Haga clic en Cancelar para deshacer los cambios.","text":"Control de arrastre, o marcador para editar función."}},"remove":{"tooltip":{"text":"Haga clic en una función para eliminar"}}},"toolbar":{"actions":{"cancel":{"text":"Cancelar","title":"Cancelar la edición, descarta todos los cambios."},"save":{"text":"Salvar","title":"Guardar cambios."}},"buttons":{"edit":"Editar las capas.","editDisabled":"No hay capas para editar.","remove":"Eliminar capas.","removeDisabled":"No hay capas que desea eliminar."}}},"fullscreenTitle":"Pantalla completa","importerButtonTitle":"Importar","zoomInTitle":"Acercarse","zoomOutTitle":"Disminuir el zoom"}},"time":{"am":"am","formats":{"compact":"% M /% d /% Y% H:% M","default":"%d %b. %Y - %H:%M:%S","devise":{"mailer":{"invitation_instructions":{"accept_until_format":"% B% d,% Y% I:% M% p"}}},"full":"%m/%d/%Y %H:%M:%S","long":"%B %d, %Y %H:%M","short":"%d %b %H:%M","time":"%H:%M"},"js_formats":{"compact":"MM/DD/YYYY HH:mm","full":"MM/DD/YYYY HH:mm:ss"},"pm":"pm"}}); diff --git a/app/helpers/backend/interventions_helper.rb b/app/helpers/backend/interventions_helper.rb index 0d0f423476..689310a60c 100644 --- a/app/helpers/backend/interventions_helper.rb +++ b/app/helpers/backend/interventions_helper.rb @@ -86,5 +86,13 @@ def add_detail_to_modal_block(title, detail, options) html.join.html_safe end end + + def add_working_period_cost(product_parameter, nature: nil) + render partial: 'intervention_costs', locals: { product_parameter: product_parameter, nature: nature } + end + + def add_total_working_period(product_parameter) + render partial: 'intervention_total_costs', locals: { product_parameter: product_parameter } + end end end diff --git a/app/models/catalog.rb b/app/models/catalog.rb index 6c34640571..e6d12e182d 100644 --- a/app/models/catalog.rb +++ b/app/models/catalog.rb @@ -39,7 +39,7 @@ class Catalog < Ekylibre::Record::Base refers_to :currency - enumerize :usage, in: %i[purchase sale stock cost], default: :sale + enumerize :usage, in: %i[purchase sale stock cost travel_cost], default: :sale # has_many :active_items, -> { where(active: true) }, class_name: "CatalogItem" has_many :items, class_name: 'CatalogItem', dependent: :destroy, inverse_of: :catalog # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`. diff --git a/app/models/document.rb b/app/models/document.rb index f97603ba42..d444961143 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -55,7 +55,7 @@ class Document < Ekylibre::Record::Base } refers_to :nature, class_name: 'DocumentNature' # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`. - validates :file_content_text, length: { maximum: 5_000_000 }, allow_blank: true + validates :file_content_text, length: { maximum: 500_000 }, allow_blank: true validates :file_content_type, :file_file_name, :file_fingerprint, length: { maximum: 500 }, allow_blank: true validates :file_file_size, numericality: { only_integer: true, greater_than: -2_147_483_649, less_than: 2_147_483_648 }, allow_blank: true validates :file_updated_at, timeliness: { on_or_after: -> { Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.now + 50.years } }, allow_blank: true diff --git a/app/models/entity.rb b/app/models/entity.rb index cb1b41a6f5..3116adc8c1 100644 --- a/app/models/entity.rb +++ b/app/models/entity.rb @@ -184,6 +184,7 @@ class Entity < Ekylibre::Record::Base scope :transporters, -> { where(transporter: true) } scope :clients, -> { where(client: true) } scope :employees, -> { where(employee: true) } + scope :company, -> { where(of_company: true) } scope :related_to, lambda { |entity| where("id IN (SELECT linked_id FROM #{EntityLink.table_name} WHERE entity_id = ?) OR id IN (SELECT entity_id FROM #{EntityLink.table_name} WHERE linked_id = ?)", entity.id, entity.id) } diff --git a/app/models/equipment.rb b/app/models/equipment.rb index 09d59df142..41e99bfdce 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -95,6 +95,14 @@ def best_activity_production(options = {}) ActivityProduction.where(support: groups_at(at)).at(at).first || super end + def tractor? + variety == :tractor + end + + def self_prepelled_equipment? + variety == :self_prepelled_equipment + end + ################################################## ### Statuses ##################################### diff --git a/app/models/intervention.rb b/app/models/intervention.rb index d0d8c39eb1..b2a52d7190 100644 --- a/app/models/intervention.rb +++ b/app/models/intervention.rb @@ -628,7 +628,6 @@ def update_compliance(modifier = {}) update(request_compliant: true) if (compliances.values - [true]).empty? end -<<<<<<< HEAD def participation(product) InterventionParticipation.of_intervention(self).of_product(product).first end @@ -659,8 +658,6 @@ def first_worker_working_period(nature: nil, not_nature: nil) byebug end -======= ->>>>>>> a0cf9a99e45e0839be671ad8f564ddbe2aee227e class << self def used_procedures select(:procedure_name).distinct.pluck(:procedure_name).map do |name| diff --git a/app/models/intervention_agent.rb b/app/models/intervention_agent.rb index d906b3e624..820561b74a 100644 --- a/app/models/intervention_agent.rb +++ b/app/models/intervention_agent.rb @@ -74,16 +74,16 @@ def cost_amount_computation(nature: nil) return InterventionParameter::AmountComputation.failed unless product quantity = Interventions::WorkingDurationService - .new(**working_duration_params) - .perform(nature: nature) + .new(**working_duration_params) + .perform(nature: nature) unit_name = Nomen::Unit.find(:hour).human_name unit_name = unit_name.pluralize if quantity > 1 options = { - catalog_usage: :cost, - quantity: working_duration.to_d / 3600, - unit_name: Nomen::Unit.find(:hour).human_name + catalog_usage: catalog_usage, + quantity: quantity, + unit_name: unit_name } options[:catalog_item] = product.default_catalog_item(options[:catalog_usage]) InterventionParameter::AmountComputation.quantity(:catalog, options) diff --git a/app/models/intervention_parameter.rb b/app/models/intervention_parameter.rb index 84138e9557..41fd84e7b0 100644 --- a/app/models/intervention_parameter.rb +++ b/app/models/intervention_parameter.rb @@ -97,6 +97,11 @@ class InterventionParameter < Ekylibre::Record::Base scope :of_actor, ->(actor) { where(product_id: actor.id) } + scope :of_variety, lambda { |intervention_id, variety| + product_nature_variant_ids = ProductNatureVariant.where(variety: variety).map(&:id) + where('intervention_id = ? AND variant_id IN (?)', intervention_id, product_nature_variant_ids).to_a + } + before_validation do self.intervention ||= group.intervention if group if reference diff --git a/app/models/intervention_participation.rb b/app/models/intervention_participation.rb index 47091a042c..fa1a460a80 100644 --- a/app/models/intervention_participation.rb +++ b/app/models/intervention_participation.rb @@ -92,6 +92,14 @@ def human_name intervention ? intervention.name : procedure_name ? I18n.t(procedure_name, scope: :procedures) : nil end + def sum_periods_of_nature(nature) + working_periods.where(nature: nature).sum(:duration) + end + + def has_period_with_nature?(nature: nil) + !working_periods.where(nature: nature).empty? + end + def qualified_human_name return if human_name.nil? || product.name.nil? working_periods.empty? ? "#{human_name} (#{product.name})" : "#{:intervention_at.tl(intervention: human_name, at: working_periods.minimum(:started_at).l)} (#{product.name})" diff --git a/app/models/intervention_working_period.rb b/app/models/intervention_working_period.rb index 24687d2155..f6e7337e3d 100644 --- a/app/models/intervention_working_period.rb +++ b/app/models/intervention_working_period.rb @@ -41,7 +41,7 @@ class InterventionWorkingPeriod < Ekylibre::Record::Base belongs_to :intervention belongs_to :intervention_participation has_one :intervention_participated_to, through: :intervention_participation, source: :intervention - enumerize :nature, in: %i[preparation travel intervention] + enumerize :nature, in: %i[preparation travel intervention pause] # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`. validates :duration, presence: true, numericality: { only_integer: true, greater_than: -2_147_483_649, less_than: 2_147_483_648 } validates :started_at, presence: true, timeliness: { on_or_after: -> { Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.now + 50.years } } @@ -96,4 +96,57 @@ class InterventionWorkingPeriod < Ekylibre::Record::Base after_commit :update_temporality, unless: -> { intervention.blank? } after_destroy :update_temporality, unless: -> { intervention.blank? } + + def hide? + started_at.to_i == stopped_at.to_i + end + + def hours_gap + (gap[:day] * 24) + gap[:hour] + end + + def minutes_gap + gap[:minute] + end + + def previous_period + return if first? + + previous_index = index - 1 + intervention_participation.working_periods.fetch(previous_index) + end + + def next_period + return if last? + + next_index = index + 1 + intervention_participation.working_periods.fetch(next_index) + end + + def pause_next? + return false if last? + gap_with_period?(next_period) + end + + def gap_with_period?(working_period) + stopped_at < working_period.started_at + end + + private + + def gap + Time.diff(stopped_at, started_at) + end + + def first? + intervention_participation.working_periods.first == self + end + + def last? + intervention_participation.working_periods.last == self + end + + def index + intervention_participation.working_periods.find_index(self) + end end diff --git a/app/themes/tekyla/stylesheets/all.scss b/app/themes/tekyla/stylesheets/all.scss index ed2b3ad2ff..d8679e0280 100644 --- a/app/themes/tekyla/stylesheets/all.scss +++ b/app/themes/tekyla/stylesheets/all.scss @@ -41,6 +41,7 @@ @import "grid"; @import "integrations"; @import "interventions"; +@import "intervention_participations"; @import "leaflet"; @import "main"; @import "map_layers"; diff --git a/app/themes/tekyla/stylesheets/interventions.scss b/app/themes/tekyla/stylesheets/interventions.scss index d797c0d450..3c4c102b8b 100644 --- a/app/themes/tekyla/stylesheets/interventions.scss +++ b/app/themes/tekyla/stylesheets/interventions.scss @@ -143,6 +143,7 @@ $preview-modal-height: 80vh; } } } +} .edit_intervention, .new_intervention { diff --git a/app/views/backend/interventions/_form.html.haml b/app/views/backend/interventions/_form.html.haml index 3650c6278f..7645201744 100644 --- a/app/views/backend/interventions/_form.html.haml +++ b/app/views/backend/interventions/_form.html.haml @@ -10,6 +10,8 @@ - action_title_key << "_#{f.object.nature}" unless f.object.record? = "actions.#{controller_path}.#{action_title_key}".t(interpolations) + = hidden_field_tag 'intervention_id', f.object.id + -# Show the different kind of intervention, or the form to create intervention - if procedure = hidden_field_tag :updater, compute_backend_interventions_path(format: :json), data: {procedure_computing: procedure.name} diff --git a/app/views/backend/interventions/_intervention_total_costs.html.haml b/app/views/backend/interventions/_intervention_total_costs.html.haml new file mode 100644 index 0000000000..ef8980d61d --- /dev/null +++ b/app/views/backend/interventions/_intervention_total_costs.html.haml @@ -0,0 +1,16 @@ +.cost + - computation = product_parameter.cost_amount_computation(nature: nil) + .computation + - if computation.failed? + = 'FAILED' + - elsif computation.none? + = '—'.html_safe + - elsif computation.quantity? + %span.quantity= computation.quantity.round(1).l(precision: 0) + %span.unit-name= computation.unit_name + %span / + - if computation.amount? + %span.amount= computation.human_amount + - else + %span.amount.no-amount + %i.icon.icon-question diff --git a/app/views/backend/interventions/_product_parameter.html.haml b/app/views/backend/interventions/_product_parameter.html.haml index 4db0ad78a5..53be0c58fe 100644 --- a/app/views/backend/interventions/_product_parameter.html.haml +++ b/app/views/backend/interventions/_product_parameter.html.haml @@ -1,40 +1,5 @@ %li.cast - .cost - - computation = product_parameter.cost_amount_computation - .computation - - if computation.failed? - = 'FAILED' - - elsif computation.none? - = '—'.html_safe - - elsif computation.quantity? - %span.quantity= computation.quantity.round(3).l(precision: 0) - %span.unit-name= computation.unit_name - = ' × '.html_safe - - if computation.sale? - = link_to(computation.human_unit_amount, {controller: :sales, action: :show, id: computation.sale.id}) - - elsif computation.purchase? - = link_to(computation.human_unit_amount, {controller: :purchases, action: :show, id: computation.purchase.id}) - - elsif computation.catalog? - - if computation.catalog_item - = link_to(computation.human_unit_amount, {controller: :catalog_items, action: :edit, id: computation.catalog_item.id, redirect: request.fullpath}) - - else - = link_to(:add_catalog_price.tl, {controller: :catalog_items, action: :new, variant_id: product_parameter.product.variant.id, catalog_id: Catalog.by_default!(computation.catalog_usage).id, redirect: request.fullpath}) - = ' = '.html_safe - - if computation.amount? - %span.amount= computation.human_amount - - else - %span.amount.no-amount - %i.icon.icon-question - - if computation.quantity? - .origin - - if computation.sale? - = :amount_computed_from.th(source: link_to(computation.sale.number, {controller: :sales, action: :show, id: computation.sale.id}, title: Sale.model_name.human)) - - elsif computation.purchase? - = :amount_computed_from.th(source: link_to(computation.purchase.number, {controller: :purchases, action: :show, id: computation.purchase.id}, title: Purchase.model_name.human)) - - elsif computation.catalog? && computation.catalog_item && computation.catalog - = :amount_estimated_from.th(source: link_to(computation.catalog.name, {controller: :catalogs, action: :show, id: computation.catalog.id}, title: Catalog.model_name.human)) - actor = product_parameter.product - - intervention = product_parameter.intervention - product = product_parameter.product diff --git a/config/locales/arb/action.yml b/config/locales/arb/action.yml index 275182c347..40c74fc4a9 100644 --- a/config/locales/arb/action.yml +++ b/config/locales/arb/action.yml @@ -969,6 +969,7 @@ arb: accounts: "حسابات المحاسب المستخدمة" accounts_only_used_at: "حسابات تستخدم فقط في" accounts_to_load: "حسابات لتحميل" + # action_duration: "Action duration" activate_entry_autocompletion: "تفعيل تكملة دخول" active: "فعال" active_balance_sheet: "رصيد دائر" #? @@ -1145,6 +1146,7 @@ arb: building_update: "تعديل موقع التخزين" #? by_year: "وبحلول العام" calculate: "حساب" + # calculated_hours: "Calculated hours" calculators: "الآلات الحاسبة" calendar: "تقويم" campaign: "حملة" diff --git a/config/locales/arb/enumerize.yml b/config/locales/arb/enumerize.yml index 7d659d35f8..816dbdcddc 100644 --- a/config/locales/arb/enumerize.yml +++ b/config/locales/arb/enumerize.yml @@ -243,6 +243,7 @@ arb: intervention_working_period: nature: intervention: "تدخل" + # pause: "Pause" preparation: "تجهيز" travel: "سفر" journal: diff --git a/config/locales/arb/support.yml b/config/locales/arb/support.yml index 4a3c552f67..df9de6546c 100644 --- a/config/locales/arb/support.yml +++ b/config/locales/arb/support.yml @@ -162,7 +162,11 @@ arb: formats: compact: "٪ م /٪ د /٪ Y٪ H:٪ M" default: "%b. %d, %Y at %H:%M:%S" + # full: "%m/%d/%Y %H:%M:%S" long: "%B %d, %Y %H:%M" short: "%d %b %H:%M" time: "%H:%M" #? + js_formats: + # compact: "MM/DD/YYYY HH:mm" + # full: "MM/DD/YYYY HH:mm:ss" pm: "مساءا" \ No newline at end of file diff --git a/config/locales/cmn/action.yml b/config/locales/cmn/action.yml index 5fe02558e0..546870d0a6 100644 --- a/config/locales/cmn/action.yml +++ b/config/locales/cmn/action.yml @@ -713,6 +713,7 @@ cmn: accounts: "帐号" accounts_only_used_at: "账户仅用于在" accounts_to_load: "账户加载" + # action_duration: "Action duration" activate_entry_autocompletion: "激活自动完成入口" active: "活性" active_finishing_after: "后主动整理" @@ -854,6 +855,7 @@ cmn: budgets: "预算" by_year: "通过一年" calculate: "计算" + # calculated_hours: "Calculated hours" calculators: "计算器" calendar: "日历" campaign: "运动" diff --git a/config/locales/cmn/enumerize.yml b/config/locales/cmn/enumerize.yml index 830fdaa994..c3fede2ce4 100644 --- a/config/locales/cmn/enumerize.yml +++ b/config/locales/cmn/enumerize.yml @@ -244,6 +244,7 @@ cmn: intervention_working_period: nature: intervention: "介入" + # pause: "Pause" preparation: "制备" travel: "旅行" journal: diff --git a/config/locales/cmn/support.yml b/config/locales/cmn/support.yml index f07914a641..df8813447b 100644 --- a/config/locales/cmn/support.yml +++ b/config/locales/cmn/support.yml @@ -125,7 +125,11 @@ cmn: formats: compact: "%M /%D /%Y%H:%M" default: "%Y年%b%d日 %A %H:%M:%S %Z" + # full: "%m/%d/%Y %H:%M:%S" long: "%Y年%b%d日 %H:%M" short: "%b%d日 %H:%M" time: "%H:%M" #? + js_formats: + # compact: "MM/DD/YYYY HH:mm" + # full: "MM/DD/YYYY HH:mm:ss" pm: "下午" \ No newline at end of file diff --git a/config/locales/deu/action.yml b/config/locales/deu/action.yml index fddb2787ca..dc14a52329 100644 --- a/config/locales/deu/action.yml +++ b/config/locales/deu/action.yml @@ -713,6 +713,7 @@ deu: # accounts: "Accounts" accounts_only_used_at: "Konten nur verwendet, um" accounts_to_load: "Konten zu laden" + # action_duration: "Action duration" activate_entry_autocompletion: "Aktivieren Sie Eintrag Auto-Vervollständigung" active: "Aktiv" active_finishing_after: "Aktive Veredelung nach" @@ -854,6 +855,7 @@ deu: budgets: "Haushalts" by_year: "Mit dem Jahr" calculate: "Berechnen" + # calculated_hours: "Calculated hours" calculators: "Taschenrechner" calendar: "Kalender" campaign: "Kampagne" diff --git a/config/locales/deu/enumerize.yml b/config/locales/deu/enumerize.yml index 01f8e8f3ac..a84ee463d0 100644 --- a/config/locales/deu/enumerize.yml +++ b/config/locales/deu/enumerize.yml @@ -244,6 +244,7 @@ deu: intervention_working_period: nature: # intervention: "Intervention" + # pause: "Pause" preparation: "Vorbereitung" travel: "Reise" journal: diff --git a/config/locales/deu/support.yml b/config/locales/deu/support.yml index 39e352c4ce..03837f406c 100644 --- a/config/locales/deu/support.yml +++ b/config/locales/deu/support.yml @@ -194,7 +194,11 @@ deu: formats: compact: "% M /% d /% Y% H:% M" default: "%A, %d. %B %Y, %H:%M Uhr" + # full: "%m/%d/%Y %H:%M:%S" long: "%A, %d. %B %Y, %H:%M Uhr" short: "%d. %B, %H:%M Uhr" time: "%H:%M" #? + js_formats: + # compact: "MM/DD/YYYY HH:mm" + # full: "MM/DD/YYYY HH:mm:ss" pm: "nachmittags" \ No newline at end of file diff --git a/config/locales/eng/action.yml b/config/locales/eng/action.yml index e4ccec2273..0f411feab2 100644 --- a/config/locales/eng/action.yml +++ b/config/locales/eng/action.yml @@ -372,6 +372,7 @@ eng: backend/intervention_participations: convert: "Convert intervention participation: %{name}" index: "Intervention participations" + # participations_modal: "Participations modal intervention participation: %{name}" backend/interventions: # change_page: "Change page intervention: %{name}" # change_state: "Change state intervention: %{name}" @@ -2371,6 +2372,7 @@ eng: notify_accountant: "Notify accountant" open: "Open" order: "Order" + # participations_modal: "Participations modal" # passthru: "Passthru" pay: "Pay" payment_gap: "Payment gap" #? diff --git a/config/locales/eng/enumerize.yml b/config/locales/eng/enumerize.yml index ebbdda7828..042c1b61e2 100644 --- a/config/locales/eng/enumerize.yml +++ b/config/locales/eng/enumerize.yml @@ -94,6 +94,7 @@ eng: purchase: "Purchase" sale: "Sale" stock: "Stock" + travel_cost: "Travel" crumb: nature: hard_start: "Hard start" @@ -232,6 +233,7 @@ eng: intervention_working_period: nature: intervention: "Intervention" + pause: "Pause" preparation: "Preparation" travel: "Travel" journal: diff --git a/config/locales/eng/support.yml b/config/locales/eng/support.yml index 84ceaf3444..4231013cfa 100644 --- a/config/locales/eng/support.yml +++ b/config/locales/eng/support.yml @@ -118,6 +118,10 @@ eng: formats: compact: "%m/%d/%Y %H:%M" default: "%b. %d, %Y at %H:%M:%S" + full: "%m/%d/%Y %H:%M:%S" long: "%B %d, %Y %H:%M" short: "%d %b %H:%M" + js_formats: + compact: "MM/DD/YYYY HH:mm" + full: "MM/DD/YYYY HH:mm:ss" pm: "pm" \ No newline at end of file diff --git a/config/locales/fra/action.yml b/config/locales/fra/action.yml index 40894f8899..bd8e0d182d 100644 --- a/config/locales/fra/action.yml +++ b/config/locales/fra/action.yml @@ -841,6 +841,7 @@ fra: accounts: "Comptes comptables" accounts_only_used_at: "Comptes utilisés seulement sur" accounts_to_load: "Plan de compte à charger" + action_duration: "Durée de l'action" activate_entry_autocompletion: "Autocompléter l’écriture" active: "Actif" active_balance_sheet: "Bilan actif" #? @@ -1014,6 +1015,7 @@ fra: buildings_map: "Carte des bâtiments" #? by_year: "Par an" calculate: "Calculer" + calculated_hours: "Horaries calculées" calculators: "Calculateurs" calendar: "Calendrier" campaign: "Campagne" diff --git a/config/locales/fra/aggregators.yml b/config/locales/fra/aggregators.yml index f0701dd86f..94858a4ac8 100644 --- a/config/locales/fra/aggregators.yml +++ b/config/locales/fra/aggregators.yml @@ -4,7 +4,7 @@ fra: started_on: "Débuté le" stopped_on: "Arrếté on" aggregator_properties: - active: "Actif" #? + active: "Actif" activity_family: "Famille d'activité" #? actor_name: "Nom de l'acteur" #? animal_group_name: "Nom du groupe d'animaux" #? @@ -16,8 +16,8 @@ fra: breeding_number: "Numéro d'élevage" campaigns: "Campagnes" capitalised_production: "Production capitalisée" #? - catalog_name: "Nom du catalogue" #? - charge_account_label: "Étiquette du compte de frais" #? + catalog_name: "Nom du catalogue" + charge_account_label: "Étiquette du compte de frais" company: "Entreprise" container_name: "Nom de l'emplacement" current_result_before_taxes: "Résultat en cours avant taxes" @@ -83,7 +83,7 @@ fra: pasturing_period: "Période pâturage" #? pasturing_working_area: "Zone de pâturage" #? payment_ratio: "Ratio de paiement" - person_name: "Nom" #? + person_name: "Nom" pictogram: "Pictogramme" picture_path: "Chemin d'image" # plan: "Plan" @@ -113,7 +113,7 @@ fra: social_expenses: "Charges sociales" #? soil_varieties: "Variétés de sol" #? sowed_at: "Semé le" #? - stock_account_label: "Étiquette du compte de stock" #? + stock_account_label: "Étiquette du compte de stock" stock_production: "Production de stock" #? stocks_variation: "Variation de stocks" #? subsidies: "Subventions" #? @@ -124,6 +124,6 @@ fra: vine_yield: "Rendement en vin" wages: "Salaires" #? working_area: "Superficie travaillée" - working_duration_in_hours: "Durée travaillée en heures" #? + working_duration_in_hours: "Durée travaillée en heures" aggregators: #? vat_register: "Registre de TVA" #? \ No newline at end of file diff --git a/config/locales/fra/enumerize.yml b/config/locales/fra/enumerize.yml index 26e7066156..e78ca5da00 100644 --- a/config/locales/fra/enumerize.yml +++ b/config/locales/fra/enumerize.yml @@ -94,6 +94,7 @@ fra: purchase: "Achat" sale: "Vente" stock: "Stock" + travel_cost: "Déplacement" crumb: nature: hard_start: "Dur début" @@ -233,6 +234,7 @@ fra: intervention_working_period: nature: intervention: "Intervention" + pause: "Pause" preparation: "Préparation" travel: "Déplacement" journal: diff --git a/config/locales/fra/support.yml b/config/locales/fra/support.yml index a71366b347..49afb4beca 100644 --- a/config/locales/fra/support.yml +++ b/config/locales/fra/support.yml @@ -120,7 +120,11 @@ fra: formats: compact: "%d/%m/%Y %H:%M" default: "%d/%m/%Y %H:%M" + full: "%d/%m/%Y %H:%M:%S" long: "%A %d %B %Y à %H:%M" short: "%d %b %H:%M" time: "%H:%M" #? + js_formats: + compact: "DD/MM/YYYY HH:mm" + full: "DD/MM/YYYY HH:mm:ss" pm: "pm" \ No newline at end of file diff --git a/config/locales/ita/action.yml b/config/locales/ita/action.yml index 5be686f164..ab529ee4e8 100644 --- a/config/locales/ita/action.yml +++ b/config/locales/ita/action.yml @@ -779,6 +779,7 @@ ita: accounts: "conti" accounts_only_used_at: "Conti utilizzati solo a" accounts_to_load: "Conti per caricare" + # action_duration: "Action duration" activate_entry_autocompletion: "Attivare l’ingresso completamento automatico" active: "Attivo" active_finishing_after: "Finitura attivo dopo" @@ -920,6 +921,7 @@ ita: budgets: "i bilanci" by_year: "Per anno" calculate: "Calcolare" + # calculated_hours: "Calculated hours" calculators: "Calcolatrici" calendar: "Calendario" campaign: "Campagna" diff --git a/config/locales/ita/enumerize.yml b/config/locales/ita/enumerize.yml index 28b6475d9c..2913753f6f 100644 --- a/config/locales/ita/enumerize.yml +++ b/config/locales/ita/enumerize.yml @@ -244,6 +244,7 @@ ita: intervention_working_period: nature: intervention: "Intervento" + # pause: "Pause" preparation: "Preparazione" travel: "Viaggio" journal: diff --git a/config/locales/ita/support.yml b/config/locales/ita/support.yml index b22358061a..1b3833b7c8 100644 --- a/config/locales/ita/support.yml +++ b/config/locales/ita/support.yml @@ -154,7 +154,11 @@ ita: formats: compact: "% M /% d /% Y% H:% M" default: "%a %d %b %Y, %H:%M:%S %z" + # full: "%m/%d/%Y %H:%M:%S" long: "%d %B %Y %H:%M" short: "%d %b %H:%M" time: "%H:%M" #? + js_formats: + # compact: "MM/DD/YYYY HH:mm" + # full: "MM/DD/YYYY HH:mm:ss" pm: "pm" \ No newline at end of file diff --git a/config/locales/jpn/action.yml b/config/locales/jpn/action.yml index 3d9a7e4bed..b8769f1b54 100644 --- a/config/locales/jpn/action.yml +++ b/config/locales/jpn/action.yml @@ -779,6 +779,7 @@ jpn: accounts: "アカウント" accounts_only_used_at: "のみで使用するアカウント" accounts_to_load: "ロードするアカウント" + # action_duration: "Action duration" activate_entry_autocompletion: "エントリの自動補完を有効にします" active: "アクティブ" active_finishing_after: "後のアクティブ仕上げ" @@ -921,6 +922,7 @@ jpn: budgets: "予算" by_year: "年度別" calculate: "計算" + # calculated_hours: "Calculated hours" calculators: "電卓" calendar: "カレンダー" campaign: "キャンペーン" diff --git a/config/locales/jpn/enumerize.yml b/config/locales/jpn/enumerize.yml index 0168dca5f6..98b1a8637d 100644 --- a/config/locales/jpn/enumerize.yml +++ b/config/locales/jpn/enumerize.yml @@ -244,6 +244,7 @@ jpn: intervention_working_period: nature: intervention: "介入" + # pause: "Pause" preparation: "準備" travel: "旅行" journal: diff --git a/config/locales/jpn/support.yml b/config/locales/jpn/support.yml index e37b79be55..0c9fd481b3 100644 --- a/config/locales/jpn/support.yml +++ b/config/locales/jpn/support.yml @@ -121,7 +121,11 @@ jpn: formats: compact: "%のM /%D /%Y%のH:%M" default: "%Y/%m/%d %H:%M:%S" + # full: "%m/%d/%Y %H:%M:%S" long: "%Y年%m月%d日(%a) %H時%M分%S秒 %z" short: "%y/%m/%d %H:%M" time: "%H:%M" #? + js_formats: + # compact: "MM/DD/YYYY HH:mm" + # full: "MM/DD/YYYY HH:mm:ss" pm: "午後" \ No newline at end of file diff --git a/config/locales/por/action.yml b/config/locales/por/action.yml index 2dc5b02a90..c8f658cc7e 100644 --- a/config/locales/por/action.yml +++ b/config/locales/por/action.yml @@ -718,6 +718,7 @@ por: accounts: "Contas" accounts_only_used_at: "Contas utilizada apenas na" accounts_to_load: "Contas para carregar" + # action_duration: "Action duration" activate_entry_autocompletion: "Ative o preenchimento automático de entrada" active: "Ativo" active_finishing_after: "Acabamento activo depois" @@ -859,6 +860,7 @@ por: budgets: "Orçamentos" by_year: "Por ano" calculate: "Calcular" + # calculated_hours: "Calculated hours" calculators: "Calculadoras" calendar: "Calendário" campaign: "Campanha" diff --git a/config/locales/por/enumerize.yml b/config/locales/por/enumerize.yml index 2c0f4d176d..68707c4a0b 100644 --- a/config/locales/por/enumerize.yml +++ b/config/locales/por/enumerize.yml @@ -246,6 +246,7 @@ por: intervention_working_period: nature: intervention: "Intervenção" + # pause: "Pause" preparation: "Preparação" travel: "Viagem" journal: diff --git a/config/locales/por/support.yml b/config/locales/por/support.yml index d5b7c9644f..75c7387539 100644 --- a/config/locales/por/support.yml +++ b/config/locales/por/support.yml @@ -120,7 +120,11 @@ por: formats: compact: "% M /% d /% Y% H:% M" default: "%a, %d de %B de %Y, %H:%M:%S" + # full: "%m/%d/%Y %H:%M:%S" long: "%d de %B de %Y, %H:%M" short: "%d de %B, %H:%M" time: "%H:%M" #? + js_formats: + # compact: "MM/DD/YYYY HH:mm" + # full: "MM/DD/YYYY HH:mm:ss" pm: "pm" \ No newline at end of file diff --git a/config/locales/spa/action.yml b/config/locales/spa/action.yml index c81dafcc0a..9840877528 100644 --- a/config/locales/spa/action.yml +++ b/config/locales/spa/action.yml @@ -773,6 +773,7 @@ spa: accounts: "Cuentos contables utilizados" accounts_only_used_at: "Solo las utilizan en" accounts_to_load: "Cuentas para cargar" + # action_duration: "Action duration" activate_entry_autocompletion: "Activar la terminación automática de entrada" active: "Activo" active_balance_sheet: "Balance activo" #? @@ -940,6 +941,7 @@ spa: building_update: "Modifiar el lugar de deposito" #? by_year: "Por año" calculate: "Calcular" + # calculated_hours: "Calculated hours" calculators: "Calculadoras" calendar: "Calendario" campaign: "Campaña" diff --git a/config/locales/spa/enumerize.yml b/config/locales/spa/enumerize.yml index 14462b522c..f09a4ad8ed 100644 --- a/config/locales/spa/enumerize.yml +++ b/config/locales/spa/enumerize.yml @@ -244,6 +244,7 @@ spa: intervention_working_period: nature: intervention: "Intervención" + # pause: "Pause" preparation: "Preparación" travel: "Viajar" journal: diff --git a/config/locales/spa/support.yml b/config/locales/spa/support.yml index 2638a3b37b..fb8534b1ef 100644 --- a/config/locales/spa/support.yml +++ b/config/locales/spa/support.yml @@ -118,7 +118,11 @@ spa: formats: compact: "% M /% d /% Y% H:% M" default: "%d %b. %Y - %H:%M:%S" + # full: "%m/%d/%Y %H:%M:%S" long: "%B %d, %Y %H:%M" short: "%d %b %H:%M" time: "%H:%M" #? + js_formats: + # compact: "MM/DD/YYYY HH:mm" + # full: "MM/DD/YYYY HH:mm:ss" pm: "pm" \ No newline at end of file diff --git a/config/navigation.xml b/config/navigation.xml index 4b9da684e1..c52ea0e159 100644 --- a/config/navigation.xml +++ b/config/navigation.xml @@ -764,6 +764,7 @@ + diff --git a/config/rights.yml b/config/rights.yml index 92baa80990..129cd20bce 100644 --- a/config/rights.yml +++ b/config/rights.yml @@ -106,7 +106,6 @@ # - "backend/helps#show" # - "backend/helps#toggle" # - "backend/inspections#export" -# - "backend/intervention_participations#create" # - "backend/intervention_participations#participations_modal" # - "backend/interventions#change_page" # - "backend/januses#toggle" diff --git a/config/routes.rb b/config/routes.rb index fa2204b8a1..b67f703da1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -590,9 +590,9 @@ end end - resources :intervention_participations, only: %i[index update destroy] do - member do - post :convert + resources :intervention_participations, only: %i[index create update destroy] do + collection do + get :participations_modal end end From 43831be543916768beb82cb5e8e99e0cb14262d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Wed, 9 Aug 2017 12:08:02 +0200 Subject: [PATCH 19/38] Clean code --- .../javascripts/backend/intervention_participations.js.coffee | 1 + app/themes/tekyla/stylesheets/interventions.scss | 1 + 2 files changed, 2 insertions(+) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index 1f7fda3afe..f3ebc24edf 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -62,6 +62,7 @@ return + $(document).on 'click', '#validParticipationsForm', (event) -> element = $(event.target) diff --git a/app/themes/tekyla/stylesheets/interventions.scss b/app/themes/tekyla/stylesheets/interventions.scss index 3c4c102b8b..a7c7c5b0ac 100644 --- a/app/themes/tekyla/stylesheets/interventions.scss +++ b/app/themes/tekyla/stylesheets/interventions.scss @@ -203,6 +203,7 @@ $preview-modal-height: 80vh; .total { background-color: rgba(black, 0.03); + min-width: 7em; .total-label { height: $fs-huge * 1.1; From e76da7f299a145ef59379af9156cefcad37ebe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Wed, 9 Aug 2017 14:46:27 +0200 Subject: [PATCH 20/38] Resolve bugs after business tests --- .../intervention_participations_controller.rb | 15 +++++++-------- app/models/intervention_agent.rb | 4 ++-- app/models/worker.rb | 5 +++++ .../working_duration_service.rb | 4 ++-- ...ntervention_participations_controller_test.rb | 1 - test/models/intervention_participation_test.rb | 16 ---------------- .../working_duration_service_test.rb | 7 +++++++ 7 files changed, 23 insertions(+), 29 deletions(-) rename app/services/{interventions => intervention}/working_duration_service.rb (96%) create mode 100644 test/services/interventions/working_duration_service_test.rb diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index 76d62cda86..84e84f39ac 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -62,12 +62,6 @@ def participations_modal @intervention = @participation.intervention - intervention_started_at = if @intervention.nil? - Time.parse(params['intervention_started_at']) - else - @intervention.started_at - end - display_calcul_mode = params[:display_calcul_mode] auto_calcul_mode = params[:auto_calcul_mode] @@ -110,6 +104,12 @@ def intervention_tool product end + def intervention_started_at + return @intervention.started_at unless @intervention.nil? + + Time.parse(params['intervention_started_at']) + end + def calculate_working_periods participations = form_participations tool = intervention_tool @@ -119,7 +119,6 @@ def calculate_working_periods participations.blank? || tool.nil? working_periods = [] - intervention_started_at = @intervention.started_at working_duration_params = { intervention: @intervention, participations: participations, product: @participation.product } @@ -128,7 +127,7 @@ def calculate_working_periods natures = %i[intervention] unless tool.try(:tractor?) natures.each do |nature| - duration = Interventions::WorkingDurationService + duration = Intervention::WorkingDurationService .new(**working_duration_params) .perform(nature: nature) diff --git a/app/models/intervention_agent.rb b/app/models/intervention_agent.rb index 820561b74a..28bece8749 100644 --- a/app/models/intervention_agent.rb +++ b/app/models/intervention_agent.rb @@ -73,7 +73,7 @@ def participation def cost_amount_computation(nature: nil) return InterventionParameter::AmountComputation.failed unless product - quantity = Interventions::WorkingDurationService + quantity = Intervention::WorkingDurationService .new(**working_duration_params) .perform(nature: nature) @@ -82,7 +82,7 @@ def cost_amount_computation(nature: nil) options = { catalog_usage: catalog_usage, - quantity: quantity, + quantity: quantity.to_d, unit_name: unit_name } options[:catalog_item] = product.default_catalog_item(options[:catalog_usage]) diff --git a/app/models/worker.rb b/app/models/worker.rb index fa3641be8d..9b89c194ed 100644 --- a/app/models/worker.rb +++ b/app/models/worker.rb @@ -99,4 +99,9 @@ class Worker < Product def participation(intervention) InterventionParticipation.find_by(product: self, intervention: intervention) end + + def working_duration(_options = {}) + InterventionWorkingPeriod.with_intervention_parameter(:doer, self) + .sum(:duration).in_second + end end diff --git a/app/services/interventions/working_duration_service.rb b/app/services/intervention/working_duration_service.rb similarity index 96% rename from app/services/interventions/working_duration_service.rb rename to app/services/intervention/working_duration_service.rb index 3ef3cf6b0b..1a0c47d992 100644 --- a/app/services/interventions/working_duration_service.rb +++ b/app/services/intervention/working_duration_service.rb @@ -1,4 +1,4 @@ -module Interventions +class Intervention class WorkingDurationService attr_reader :intervention, :participations, :participation, :product @@ -10,7 +10,7 @@ def initialize(intervention: nil, participations: [], participation: nil, produc end def perform(nature: nil, not_nature: nil) - return @intervention.working_duration.to_d / 3600 if @participations.empty? && @participation.nil? + return @intervention.working_duration.to_d if @participations.empty? && @participation.nil? return worker_working_duration(nature) if worker? diff --git a/test/controllers/backend/intervention_participations_controller_test.rb b/test/controllers/backend/intervention_participations_controller_test.rb index 9db57e8c6a..5234d3b8ae 100644 --- a/test/controllers/backend/intervention_participations_controller_test.rb +++ b/test/controllers/backend/intervention_participations_controller_test.rb @@ -1,6 +1,5 @@ require 'test_helper' module Backend class InterventionParticipationsControllerTest < ActionController::TestCase - test_restfully_all_actions convert: :touch end end diff --git a/test/models/intervention_participation_test.rb b/test/models/intervention_participation_test.rb index 5b2ef56f86..4d6686c237 100644 --- a/test/models/intervention_participation_test.rb +++ b/test/models/intervention_participation_test.rb @@ -145,22 +145,6 @@ class InterventionParticipationTest < ActiveSupport::TestCase assert_equal false, non_comp_int.request_compliant end - test 'working periods in a participation shouldn\'t be able to overlap' do - now = Time.zone.now - @participation.working_periods.create!( - nature: :travel, - started_at: now, - stopped_at: now + 1.hour - ) - assert_raises do - @participation.working_periods.create!( - nature: :intervention, - started_at: now - 30.minutes, - stopped_at: now + 30.minutes - ) - end - end - def fake_working_periods now = Time.zone.now [ diff --git a/test/services/interventions/working_duration_service_test.rb b/test/services/interventions/working_duration_service_test.rb new file mode 100644 index 0000000000..b0a3011a92 --- /dev/null +++ b/test/services/interventions/working_duration_service_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +module Interventions + class WorkingDurationServiceTest < ActiveSupport::TestCase + # Add tests here... + end +end \ No newline at end of file From 1cafea22ca88e7b07ba4e5f0b840d93973047e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Wed, 9 Aug 2017 17:08:11 +0200 Subject: [PATCH 21/38] Resolve errors after business tests --- app/assets/javascripts/backend/interventions.js.coffee | 8 -------- .../backend/intervention_participations_controller.rb | 2 -- app/models/intervention_working_period.rb | 4 ++++ app/services/intervention/working_duration_service.rb | 10 +++++++--- .../_participations_modal.html.haml | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/backend/interventions.js.coffee b/app/assets/javascripts/backend/interventions.js.coffee index fecb050de0..9c4f5d4258 100644 --- a/app/assets/javascripts/backend/interventions.js.coffee +++ b/app/assets/javascripts/backend/interventions.js.coffee @@ -206,16 +206,9 @@ if intervention_id == "" interventionStartedAt = $('.intervention-started-at').val() - displayCalculMode = false - if $(targetted_element).closest('.nested-driver, .nested-doer').length > 0 && $('input[name="display-calcul-mode"]').length == 0 - $('.simple_form').append('') - displayCalculMode = true - autoCalculMode = true if $('input[name="auto-calcul-mode"]').length == 0 $('.simple_form').append('') - #else if existingParticipation && existingParticipation != "" - #autoCalculMode = false else autoCalculMode = $('input[name="auto-calcul-mode"]').val() @@ -226,7 +219,6 @@ datas['existing_participation'] = existingParticipation datas['participations'] = participations datas['intervention_started_at'] = interventionStartedAt - datas['display_calcul_mode'] = displayCalculMode datas['auto_calcul_mode'] = autoCalculMode $.ajax diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index 84e84f39ac..718cc8faf3 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -62,7 +62,6 @@ def participations_modal @intervention = @participation.intervention - display_calcul_mode = params[:display_calcul_mode] auto_calcul_mode = params[:auto_calcul_mode] render partial: 'backend/intervention_participations/participations_modal', @@ -70,7 +69,6 @@ def participations_modal participation: @participation, intervention_started_at: intervention_started_at, tool: intervention_tool, - display_calcul_mode: display_calcul_mode, auto_calcul_mode: auto_calcul_mode, calculate_working_periods: calculate_working_periods } diff --git a/app/models/intervention_working_period.rb b/app/models/intervention_working_period.rb index f6e7337e3d..79dda9cf80 100644 --- a/app/models/intervention_working_period.rb +++ b/app/models/intervention_working_period.rb @@ -132,6 +132,10 @@ def gap_with_period?(working_period) stopped_at < working_period.started_at end + def duration_gap + (stopped_at - started_at) / 3600 + end + private def gap diff --git a/app/services/intervention/working_duration_service.rb b/app/services/intervention/working_duration_service.rb index 1a0c47d992..e19ea664fb 100644 --- a/app/services/intervention/working_duration_service.rb +++ b/app/services/intervention/working_duration_service.rb @@ -10,7 +10,7 @@ def initialize(intervention: nil, participations: [], participation: nil, produc end def perform(nature: nil, not_nature: nil) - return @intervention.working_duration.to_d if @participations.empty? && @participation.nil? + return intervention_working_duration if @participations.empty? && @participation.nil? return worker_working_duration(nature) if worker? @@ -45,7 +45,11 @@ def worker_working_duration(nature) .inject(0, :+) end - duration / 3600 + duration.to_d / 3600 + end + + def intervention_working_duration + @intervention.working_duration.to_d / 3600 end def worker? @@ -102,7 +106,7 @@ def prepelled_equipments_count def workers_times(nature: nil, not_nature: nil) worker_working_periods(nature, not_nature) - .map(&:hours_gap) + .map(&:duration_gap) .reduce(0, :+) end diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 5d87d9d08a..d2abfa941d 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -53,9 +53,9 @@ .picto.picto-pause-circle-outline %span= I18n.t('enumerize.intervention_working_period.nature.pause') - - classes = 'hidden' if display_calcul_mode.to_sym == :false + - classes = 'hidden' unless tool.nil? %div{ class: "auto-calculate-equipments #{ classes }"} - = check_box 'participation', "auto_calculate_equipments", checked: true + = check_box 'participation', "auto_calculate_equipments", checked: auto_calcul_mode.to_sym == :true %span Mode de calcul automatique %p En mode automatique, les périodes de déplacement et d'intervention des tracteurs et outils seront calculés à partir de la moyenne des périodes des opérateurs. From cef87c525f9c713a2ab18687e1094127d16f045e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 10 Aug 2017 12:36:41 +0200 Subject: [PATCH 22/38] Add working duration service test --- .../intervention_participations_controller.rb | 2 +- app/models/intervention_agent.rb | 2 +- .../working_duration_service.rb | 2 +- ...rvention_participations_controller_test.rb | 16 - .../working_duration_service_test.rb | 282 ++++++++++++++++++ .../working_duration_service_test.rb | 7 - 6 files changed, 285 insertions(+), 26 deletions(-) rename app/services/{intervention => interventions}/working_duration_service.rb (99%) create mode 100644 test/services/intervention/working_duration_service_test.rb delete mode 100644 test/services/interventions/working_duration_service_test.rb diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index 718cc8faf3..d347c71ac5 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -125,7 +125,7 @@ def calculate_working_periods natures = %i[intervention] unless tool.try(:tractor?) natures.each do |nature| - duration = Intervention::WorkingDurationService + duration = Interventions::WorkingDurationService .new(**working_duration_params) .perform(nature: nature) diff --git a/app/models/intervention_agent.rb b/app/models/intervention_agent.rb index 28bece8749..9aa298df7b 100644 --- a/app/models/intervention_agent.rb +++ b/app/models/intervention_agent.rb @@ -73,7 +73,7 @@ def participation def cost_amount_computation(nature: nil) return InterventionParameter::AmountComputation.failed unless product - quantity = Intervention::WorkingDurationService + quantity = Interventions::WorkingDurationService .new(**working_duration_params) .perform(nature: nature) diff --git a/app/services/intervention/working_duration_service.rb b/app/services/interventions/working_duration_service.rb similarity index 99% rename from app/services/intervention/working_duration_service.rb rename to app/services/interventions/working_duration_service.rb index e19ea664fb..ccfeafa127 100644 --- a/app/services/intervention/working_duration_service.rb +++ b/app/services/interventions/working_duration_service.rb @@ -1,4 +1,4 @@ -class Intervention +module Interventions class WorkingDurationService attr_reader :intervention, :participations, :participation, :product diff --git a/test/controllers/api/v1/intervention_participations_controller_test.rb b/test/controllers/api/v1/intervention_participations_controller_test.rb index a33468280b..0dab7dd9a3 100644 --- a/test/controllers/api/v1/intervention_participations_controller_test.rb +++ b/test/controllers/api/v1/intervention_participations_controller_test.rb @@ -79,22 +79,6 @@ class InterventionParticipationsControllerTest < ActionController::TestCase # assert_equal original_count, new_count # end - test 'ignores overlapping working periods' do - add_auth_header - payload = overlapping_payload - - part_id = JSON(post(:create, payload).body)['id'] - original_count = InterventionParticipation.find(part_id).working_periods.count - - assert_equal 1, original_count - - payload = overlapping_payload(only_overlap: true) - part_id = JSON(post(:create, payload).body)['id'] - new_count = InterventionParticipation.find(part_id).working_periods.count - - assert_equal original_count, new_count - end - test 'created working_periods have the correct nature' do add_auth_header diff --git a/test/services/intervention/working_duration_service_test.rb b/test/services/intervention/working_duration_service_test.rb new file mode 100644 index 0000000000..d29fdc498b --- /dev/null +++ b/test/services/intervention/working_duration_service_test.rb @@ -0,0 +1,282 @@ +require 'test_helper' + +module Interventions + class WorkingDurationServiceTest < ActiveSupport::TestCase + setup do + @now = Time.zone.now + + create_workers + create_equipments + create_intervention + create_participations + + @intervention.reload + end + + test 'no participations return intervention working period' do + duration = Interventions::WorkingDurationService + .new(**working_duration_params) + .perform(nature: :intervention) + + assert_equal duration, (@intervention.working_duration / 3600).to_d + end + + test 'no nature specified return sum of working periods for worker' do + working_params = working_duration_params(participation: @alice_participation, + product: @alice) + + duration = Interventions::WorkingDurationService + .new(working_params) + .perform + + sum_working_periods = @alice_participation + .working_periods + .map(&:duration) + .inject(0, :+) + .to_d + + assert_equal duration, (sum_working_periods / 3600).to_d + end + + test 'return sum of specified nature working periods for worker' do + working_params = working_duration_params(participation: @alice_participation, + product: @alice) + + intervention_duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :intervention) + + sum_working_periods = sum_working_periods_of(participation: @alice_participation, nature: :intervention) + + assert_equal intervention_duration, (sum_working_periods.to_d / 3600).to_d + + travel_duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :travel) + + sum_working_periods = sum_working_periods_of(participation: @alice_participation, nature: :travel) + + assert_equal travel_duration, (sum_working_periods.to_d / 3600).to_d + end + + test 'tool working duration without any tractors or tools return intervention working duration' do + working_params = working_duration_params(participations: @participations, + product: Plant.first) + + duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :intervention) + + assert_equal duration, @intervention.working_duration + end + + test 'test tractor calculated working duration' do + working_params = working_duration_params(participations: @participations, + product: @tractor) + + intervention_duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :intervention) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) + + assert_equal intervention_duration, (sum_working_periods.to_d / 1).to_d + + travel_duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :travel) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :travel) + + assert_equal travel_duration, (sum_working_periods.to_d / 1).to_d + end + + test 'divise calculated working duration by two if they have two tractors' do + working_params = working_duration_params(participations: @participations, + product: @tractor) + + intervention_duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :intervention) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) + + @participations << @second_tractor_participation + + working_params = working_duration_params(participations: @participations, + product: @tractor) + + intervention_duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :intervention) + + assert_equal (sum_working_periods / 2).to_d.round(2), intervention_duration.round(2) + end + + test 'test tool calculated working duration' do + working_params = working_duration_params(participations: @participations, + product: @tool) + + intervention_duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :intervention) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) + + assert_equal intervention_duration, (sum_working_periods.to_d / 1).to_d + + travel_duration = Interventions::WorkingDurationService + .new(working_params) + .perform(nature: :travel) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :travel) + + assert_equal travel_duration, (sum_working_periods.to_d / 1).to_d + end + + private + + def sum_working_periods_of(participation: nil, participations: {}, nature: nil) + unless participations.empty? + return participations + .map(&:working_periods) + .flatten + .select{ |working_period| working_period.nature == nature } + .map(&:duration_gap) + .inject(0, :+) + end + + participation + .working_periods + .select{ |working_period| working_period.nature.to_sym == nature } + .map(&:duration) + .inject(0, :+) + end + + def working_duration_params(participations: {}, participation: nil, product: nil) + unless participations.empty? + return { intervention: @intervention, + participations: participations, + product: product } + end + + { intervention: @intervention, + participation: participation, + product: product } + end + + def fake_working_periods + now = Time.zone.now + [ + InterventionWorkingPeriod.new(started_at: now - 3.hours, stopped_at: now - 2.hours, nature: 'preparation'), + InterventionWorkingPeriod.new(started_at: now - 2.hours, stopped_at: now - 90.minutes, nature: 'travel'), + InterventionWorkingPeriod.new(started_at: now - 90.minutes, stopped_at: now - 30.minutes, nature: 'intervention'), + InterventionWorkingPeriod.new(started_at: now - 30.minutes, stopped_at: now, nature: 'travel') + ] + end + + def create_workers + @alice = Worker.create!( + name: 'Alice', + variety: 'worker', + variant: ProductNatureVariant.first, + person: Entity.contacts.first + ) + + @john = Worker.create!( + name: 'John', + variety: 'worker', + variant: ProductNatureVariant.first, + person: Entity.contacts.last + ) + end + + def create_equipments + @tractor = Equipment.create!( + name: "Fake tractor", + variety: 'tractor', + variant: ProductNatureVariant.where(variety: 'tractor').first + ) + + @second_tractor = Equipment.create!( + name: "Fake second tractor", + variety: 'tractor', + variant: ProductNatureVariant.where(variety: 'tractor').first + ) + + @tool = Equipment.create!( + name: "Fake seeder", + variety: 'trailed_equipment', + variant: ProductNatureVariant.where(variety: 'trailed_equipment').first + ) + end + + def create_intervention + @intervention = Intervention.create!( + procedure_name: :sowing, + actions: [:sowing], + request_compliant: false, + working_periods: fake_working_periods + ) + + @intervention.doers.create!( + product: @alice, + reference_name: 'land_parcel' + ) + + @intervention.doers.create!( + product: @john, + reference_name: 'land_parcel' + ) + end + + def create_participations + @alice_participation = InterventionParticipation.create!( + state: :done, + request_compliant: false, + procedure_name: :sowing, + product: @alice, + working_periods_attributes: [ + { + started_at: @now - 1.hour, + stopped_at: @now - 30.minutes, + nature: 'travel' + }, + { + started_at: @now - 30.minutes, + stopped_at: @now - 15.minutes, + nature: 'intervention' + }, + { + started_at: @now - 10.minutes, + stopped_at: @now, + nature: 'intervention' + } + ] + ) + + @john_participation = InterventionParticipation.create!( + state: :done, + request_compliant: false, + procedure_name: :sowing, + product: @john, + working_periods_attributes: [ + { + started_at: @now - 1.hour, + stopped_at: @now, + nature: 'intervention' + } + ] + ) + + @second_tractor_participation = InterventionParticipation.create!( + state: :done, + request_compliant: false, + procedure_name: :sowing, + product: @second_tractor + ) + + @participations = [@alice_participation, @john_participation] + end + end +end \ No newline at end of file diff --git a/test/services/interventions/working_duration_service_test.rb b/test/services/interventions/working_duration_service_test.rb deleted file mode 100644 index b0a3011a92..0000000000 --- a/test/services/interventions/working_duration_service_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -module Interventions - class WorkingDurationServiceTest < ActiveSupport::TestCase - # Add tests here... - end -end \ No newline at end of file From dd5ccfdf6ea377679f06e79661019a152ed59dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 10 Aug 2017 12:36:56 +0200 Subject: [PATCH 23/38] Remove byebug (oops) --- app/models/intervention.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/intervention.rb b/app/models/intervention.rb index b2a52d7190..445aec05fa 100644 --- a/app/models/intervention.rb +++ b/app/models/intervention.rb @@ -655,7 +655,6 @@ def drivers_times(nature: nil, not_nature: nil) def first_worker_working_period(nature: nil, not_nature: nil) test = worker_working_periods(nature: nature, not_nature: not_nature) - byebug end class << self From 742ebfc7d08e32ffc904b6e48642e7ce1096d596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 10 Aug 2017 15:28:17 +0200 Subject: [PATCH 24/38] Add travel time in show view for tractors --- .../backend/interventions/_product_parameter.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/backend/interventions/_product_parameter.html.haml b/app/views/backend/interventions/_product_parameter.html.haml index 53be0c58fe..152ae40a91 100644 --- a/app/views/backend/interventions/_product_parameter.html.haml +++ b/app/views/backend/interventions/_product_parameter.html.haml @@ -13,21 +13,21 @@ .period .period-type = image_tag('intervention_participations/action-preparation.svg', class: "period-icon") - %h3{ class: "period-label" }= t('enumerize.intervention_working_period.preparation') + %h3{ class: "period-label" }= t('enumerize.intervention_working_period.nature.preparation') = add_working_period_cost(product_parameter, nature: :preparation) - - if !participation.nil? && participation.has_period_with_nature?(nature: :travel) + - if !participation.nil? && participation.has_period_with_nature?(nature: :travel) || product.try(:tractor?) .period .period-type = image_tag('intervention_participations/action-travel.svg', class: "period-icon") - %h3{ class: "period-label" }= t('enumerize.intervention_working_period.travel') + %h3{ class: "period-label" }= t('enumerize.intervention_working_period.nature.travel') = add_working_period_cost(product_parameter, nature: :travel) - if (!participation.nil? && participation.has_period_with_nature?(nature: :intervention)) || product.is_a?(Equipment) .period .period-type = image_tag('intervention_participations/action-intervention.svg', class: "period-icon") - %h3{ class: "period-label" }= t('enumerize.intervention_working_period.intervention') + %h3{ class: "period-label" }= t('enumerize.intervention_working_period.nature.intervention') = add_working_period_cost(product_parameter, nature: :intervention) .total From 0e84b3c1d8c382d700f34abb8e25552b10f38279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 10 Aug 2017 17:20:18 +0200 Subject: [PATCH 25/38] Fix errors with totals --- app/helpers/backend/interventions_helper.rb | 4 +-- app/models/intervention_agent.rb | 27 ++++++++++++++++--- .../_intervention_total_costs.html.haml | 2 +- .../_product_parameter.html.haml | 8 +++++- .../backend/interventions/show.html.haml | 6 ++--- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/app/helpers/backend/interventions_helper.rb b/app/helpers/backend/interventions_helper.rb index 689310a60c..f3cdddebe1 100644 --- a/app/helpers/backend/interventions_helper.rb +++ b/app/helpers/backend/interventions_helper.rb @@ -91,8 +91,8 @@ def add_working_period_cost(product_parameter, nature: nil) render partial: 'intervention_costs', locals: { product_parameter: product_parameter, nature: nature } end - def add_total_working_period(product_parameter) - render partial: 'intervention_total_costs', locals: { product_parameter: product_parameter } + def add_total_working_period(product_parameter, natures: {}) + render partial: 'intervention_total_costs', locals: { product_parameter: product_parameter, natures: natures } end end end diff --git a/app/models/intervention_agent.rb b/app/models/intervention_agent.rb index 9aa298df7b..fb498d27a9 100644 --- a/app/models/intervention_agent.rb +++ b/app/models/intervention_agent.rb @@ -70,12 +70,14 @@ def participation end end - def cost_amount_computation(nature: nil) + def cost_amount_computation(nature: nil, natures: {}) return InterventionParameter::AmountComputation.failed unless product - quantity = Interventions::WorkingDurationService - .new(**working_duration_params) - .perform(nature: nature) + if natures.empty? + quantity = nature_quantity(nature) + else + quantity = natures_quantity(natures) + end unit_name = Nomen::Unit.find(:hour).human_name unit_name = unit_name.pluralize if quantity > 1 @@ -85,6 +87,7 @@ def cost_amount_computation(nature: nil) quantity: quantity.to_d, unit_name: unit_name } + options[:catalog_item] = product.default_catalog_item(options[:catalog_usage]) InterventionParameter::AmountComputation.quantity(:catalog, options) end @@ -95,6 +98,22 @@ def working_duration_params product: product } end + def natures_quantity(natures) + quantity = 0 + + natures.each do |nature| + quantity += nature_quantity(nature) + end + + quantity + end + + def nature_quantity(nature) + Interventions::WorkingDurationService + .new(**working_duration_params) + .perform(nature: nature) + end + def catalog_usage :cost end diff --git a/app/views/backend/interventions/_intervention_total_costs.html.haml b/app/views/backend/interventions/_intervention_total_costs.html.haml index ef8980d61d..4e25616816 100644 --- a/app/views/backend/interventions/_intervention_total_costs.html.haml +++ b/app/views/backend/interventions/_intervention_total_costs.html.haml @@ -1,5 +1,5 @@ .cost - - computation = product_parameter.cost_amount_computation(nature: nil) + - computation = product_parameter.cost_amount_computation(natures: natures) .computation - if computation.failed? = 'FAILED' diff --git a/app/views/backend/interventions/_product_parameter.html.haml b/app/views/backend/interventions/_product_parameter.html.haml index 152ae40a91..81aec262d6 100644 --- a/app/views/backend/interventions/_product_parameter.html.haml +++ b/app/views/backend/interventions/_product_parameter.html.haml @@ -32,7 +32,13 @@ .total %h3{ class: "total-label" }= t('labels.total') - = add_total_working_period(product_parameter) + + - if product.is_a?(Worker) + = add_total_working_period(product_parameter) + - elsif product.try(:tractor?) + = add_total_working_period(product_parameter, natures: %i[travel intervention]) + - else + = add_total_working_period(product_parameter, natures: %i[intervention]) - variant = product_parameter.variant - if actor diff --git a/app/views/backend/interventions/show.html.haml b/app/views/backend/interventions/show.html.haml index deaed713cc..1ca871405c 100644 --- a/app/views/backend/interventions/show.html.haml +++ b/app/views/backend/interventions/show.html.haml @@ -85,17 +85,17 @@ %span.title= I18n.t('enumerize.intervention_working_period.nature.preparation') %span.value %i.picto.picto-clock-o - = human_duration(resource.working_duration_of_nature(:preparation)) + = human_duration(resource.drivers_times(nature: :preparation)) .med-info %span.title= I18n.t('enumerize.intervention_working_period.nature.travel') %span.value %i.picto.picto-clock-o - = human_duration(resource.working_duration_of_nature(:travel)) + = human_duration(resource.drivers_times(nature: :travel)) .med-info %span.title= I18n.t('enumerize.intervention_working_period.nature.intervention') %span.value %i.picto.picto-clock-o - = human_duration(resource.working_duration_of_nature(:intervention)) + = human_duration(resource.drivers_times(nature: :intervention)) -# if resource.production_support .info From e46d6e1311236b51d49e92249c3122d368a6fa67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 10 Aug 2017 17:26:26 +0200 Subject: [PATCH 26/38] Fix whole_duration and working_duration totals --- app/views/backend/interventions/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/backend/interventions/show.html.haml b/app/views/backend/interventions/show.html.haml index 1ca871405c..6445e55bd8 100644 --- a/app/views/backend/interventions/show.html.haml +++ b/app/views/backend/interventions/show.html.haml @@ -75,12 +75,12 @@ %span.title= Intervention.human_attribute_name(:working_duration) %span.value %i.picto.picto-timelapse - = human_duration(resource.working_duration) + = human_duration(resource.drivers_times(nature: :intervention)) .med-info %span.title= Intervention.human_attribute_name(:whole_duration) %span.value %i.picto.picto-timelapse - = human_duration(resource.whole_duration) + = human_duration(resource.drivers_times(nature: nil)) .med-info %span.title= I18n.t('enumerize.intervention_working_period.nature.preparation') %span.value From 9f2a8e84f51e797fd6528adabb5042f68339f7c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 10 Aug 2017 17:38:47 +0200 Subject: [PATCH 27/38] Fix interventions general totals --- app/models/intervention.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/intervention.rb b/app/models/intervention.rb index 445aec05fa..ea05210583 100644 --- a/app/models/intervention.rb +++ b/app/models/intervention.rb @@ -633,15 +633,15 @@ def participation(product) end def worker_working_periods(nature: nil, not_nature: nil) - participations.select { |participation| participation.product.is_a?(Worker) } + workers_participations = participations.select { |participation| participation.product.is_a?(Worker) } working_periods = nil if nature.nil? && not_nature.nil? - working_periods = participations.map(&:working_periods) + working_periods = workers_participations.map(&:working_periods) elsif !nature.nil? - working_periods = participations.map { |participation| participation.working_periods.where(nature: nature) } + working_periods = workers_participations.map { |participation| participation.working_periods.where(nature: nature) } elsif !not_nature.nil? - working_periods = participations.map { |participation| participation.working_periods.where.not(nature: not_nature) } + working_periods = workers_participations.map { |participation| participation.working_periods.where.not(nature: not_nature) } end working_periods.flatten From 974b54e6b1c6a06403137d553ea705a4fb7a474d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Fri, 11 Aug 2017 16:42:48 +0200 Subject: [PATCH 28/38] Add overlap working periods validation --- app/models/intervention_working_period.rb | 6 ++++++ ...tervention_participations_controller_test.rb | 16 ++++++++++++++++ test/models/intervention_participation_test.rb | 17 +++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/app/models/intervention_working_period.rb b/app/models/intervention_working_period.rb index 79dda9cf80..26ac7ebcb8 100644 --- a/app/models/intervention_working_period.rb +++ b/app/models/intervention_working_period.rb @@ -92,6 +92,12 @@ class InterventionWorkingPeriod < Ekylibre::Record::Base if started_at && stopped_at && stopped_at <= started_at errors.add(:stopped_at, :posterior, to: started_at.l) end + + if intervention_participation.present? + siblings = intervention_participation.working_periods.where.not(id: id || 0) + errors.add(:started_at, :overlap_sibling) if siblings.where('started_at <= ? AND ? <= stopped_at', started_at, started_at).any? + errors.add(:stopped_at, :overlap_sibling) if siblings.where('started_at <= ? AND ? <= stopped_at', stopped_at, stopped_at).any? + end end after_commit :update_temporality, unless: -> { intervention.blank? } diff --git a/test/controllers/api/v1/intervention_participations_controller_test.rb b/test/controllers/api/v1/intervention_participations_controller_test.rb index 0dab7dd9a3..d8ef0ca64e 100644 --- a/test/controllers/api/v1/intervention_participations_controller_test.rb +++ b/test/controllers/api/v1/intervention_participations_controller_test.rb @@ -79,6 +79,22 @@ class InterventionParticipationsControllerTest < ActionController::TestCase # assert_equal original_count, new_count # end + test 'ignores overlapping working periods' do + add_auth_header + payload = overlapping_payload + + part_id = JSON(post(:create, payload).body)['id'] + original_count = InterventionParticipation.find(part_id).working_periods.count + + assert_equal 1, original_count + + payload = overlapping_payload(only_overlap: true) + part_id = JSON(post(:create, payload).body)['id'] + new_count = InterventionParticipation.find(part_id).working_periods.count + + assert_equal original_count, new_count + end + test 'created working_periods have the correct nature' do add_auth_header diff --git a/test/models/intervention_participation_test.rb b/test/models/intervention_participation_test.rb index 4d6686c237..f93ecace32 100644 --- a/test/models/intervention_participation_test.rb +++ b/test/models/intervention_participation_test.rb @@ -145,6 +145,23 @@ class InterventionParticipationTest < ActiveSupport::TestCase assert_equal false, non_comp_int.request_compliant end + test 'working periods in a participation shouldn\'t be able to overlap' do + now = Time.zone.now + @participation.working_periods.create!( + nature: :travel, + started_at: now, + stopped_at: now + 1.hour + ) + + assert_raises do + @participation.working_periods.create!( + nature: :intervention, + started_at: now - 30.minutes, + stopped_at: now + 30.minutes + ) + end + end + def fake_working_periods now = Time.zone.now [ From 3cd2cd5c4cecd8ff61962f6ae2cd6ff524550239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Fri, 11 Aug 2017 17:12:11 +0200 Subject: [PATCH 29/38] Correct overlap working periods for test --- app/models/intervention_working_period.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/intervention_working_period.rb b/app/models/intervention_working_period.rb index 26ac7ebcb8..3ea5c1c2d4 100644 --- a/app/models/intervention_working_period.rb +++ b/app/models/intervention_working_period.rb @@ -95,8 +95,8 @@ class InterventionWorkingPeriod < Ekylibre::Record::Base if intervention_participation.present? siblings = intervention_participation.working_periods.where.not(id: id || 0) - errors.add(:started_at, :overlap_sibling) if siblings.where('started_at <= ? AND ? <= stopped_at', started_at, started_at).any? - errors.add(:stopped_at, :overlap_sibling) if siblings.where('started_at <= ? AND ? <= stopped_at', stopped_at, stopped_at).any? + errors.add(:started_at, :overlap_sibling) if siblings.where('started_at <= ? AND ? < stopped_at', started_at, started_at).any? + errors.add(:stopped_at, :overlap_sibling) if siblings.where('started_at < ? AND ? <= stopped_at', stopped_at, stopped_at).any? end end From 39d9c6b73b98b715764686978712036397dd790c Mon Sep 17 00:00:00 2001 From: Brice TEXIER Date: Fri, 11 Aug 2017 18:58:56 +0200 Subject: [PATCH 30/38] Restores test/controllers/backend/intervention_participations_controller_test.rb --- .../backend/intervention_participations_controller_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/controllers/backend/intervention_participations_controller_test.rb b/test/controllers/backend/intervention_participations_controller_test.rb index 5234d3b8ae..9db57e8c6a 100644 --- a/test/controllers/backend/intervention_participations_controller_test.rb +++ b/test/controllers/backend/intervention_participations_controller_test.rb @@ -1,5 +1,6 @@ require 'test_helper' module Backend class InterventionParticipationsControllerTest < ActionController::TestCase + test_restfully_all_actions convert: :touch end end From 9400e518d3154a3588e364561353661d8e15ce5d Mon Sep 17 00:00:00 2001 From: Brice TEXIER Date: Fri, 11 Aug 2017 19:00:06 +0200 Subject: [PATCH 31/38] Normalize "intervention working time duration calculation" service name --- ...rking_time_duration_calculation_service.rb | 138 +++++++++ .../interventions/working_duration_service.rb | 144 --------- .../working_duration_service_test.rb | 282 ------------------ ..._time_duration_calculation_service_test.rb | 280 +++++++++++++++++ 4 files changed, 418 insertions(+), 426 deletions(-) create mode 100644 app/services/intervention_working_time_duration_calculation_service.rb delete mode 100644 app/services/interventions/working_duration_service.rb delete mode 100644 test/services/intervention/working_duration_service_test.rb create mode 100644 test/services/intervention_working_time_duration_calculation_service_test.rb diff --git a/app/services/intervention_working_time_duration_calculation_service.rb b/app/services/intervention_working_time_duration_calculation_service.rb new file mode 100644 index 0000000000..5b6d2903b3 --- /dev/null +++ b/app/services/intervention_working_time_duration_calculation_service.rb @@ -0,0 +1,138 @@ +# Permits to compute working time by nature (doer, tool) in intervention +# context. +class InterventionWorkingTimeDurationCalculationService + attr_reader :intervention, :participations, :participation, :product + + def initialize(intervention: nil, participations: [], participation: nil, product: nil) + @intervention = intervention + @participations = participations + @participation = participation + @product = product + end + + # TODO: Documentation on not_nature parameter + def perform(nature: nil, not_nature: nil) + return intervention_working_duration if @participations.empty? && @participation.nil? + + return worker_working_duration(nature) if worker? + + times = workers_times(nature: nature, not_nature: not_nature) + + if times == 0 || + (tractors_count == 0 && prepelled_equipments_count == 0 && tools_count == 0) + return @intervention.working_duration + end + + return times.to_d / tools_count if tool? + + times.to_d / (tractors_count + prepelled_equipments_count) + end + + private + + def worker_working_duration(nature) + duration = if nature.nil? + @participation + .working_periods + .map(&:duration) + .inject(0, :+) + else + @participation + .working_periods + .select { |working_period| working_period.nature.to_sym == nature } + .map(&:duration) + .inject(0, :+) + end + + duration.to_d / 3600 + end + + def intervention_working_duration + @intervention.working_duration.to_d / 3600 + end + + def worker? + @product.is_a?(Worker) + end + + def tractor? + @product.is_a?(Equipment) && @product.try(:tractor?) + end + + def self_prepelled_equipment? + @product.variety.to_sym == :self_prepelled_equipment + end + + def tool? + @product.is_a?(Equipment) && product.try(:tractor?) == false + end + + def tractors_count + count = @participations + .select { |participation| participation.product.try(:tractor?) } + .size + + count += 1 if tractor? && !product_participation? + + count + end + + def tools_count + count = @participations + .select { |participation| participation.product.is_a?(Equipment) && participation.product.try(:tractor?) == false } + .size + + count += 1 if !tractor? && tool? && !product_participation? + + count + end + + def product_participation? + @participations + .select { |participation| participation.product == @product } + .present? + end + + def prepelled_equipments_count + @participations + .select { |participation| participation.product.variety.to_sym == :self_prepelled_equipment } + .size + end + + def workers_times(nature: nil, not_nature: nil) + worker_working_periods(nature, not_nature) + .map(&:duration_gap) + .reduce(0, :+) + end + + def worker_working_periods(nature, not_nature) + participations = @participations.select { |participation| participation.product.is_a?(Worker) } + working_periods = nil + + if nature.nil? && not_nature.nil? + return participations.map(&:working_periods).flatten + end + + unless nature.nil? + return working_periods_of_nature(participations, nature) + end + + working_periods_not_nature(participations, nature) + end + + def working_periods_of_nature(participations, nature, reverse_result: false) + participations.map do |participation| + participation.working_periods.select do |working_period| + if reverse_result == false + working_period.nature.to_sym == nature + else + working_period.nature.to_sym != nature + end + end + end.flatten + end + + def working_periods_not_nature(participations, nature) + working_periods_of_nature(participations, nature, reverse_result: true) + end +end diff --git a/app/services/interventions/working_duration_service.rb b/app/services/interventions/working_duration_service.rb deleted file mode 100644 index ccfeafa127..0000000000 --- a/app/services/interventions/working_duration_service.rb +++ /dev/null @@ -1,144 +0,0 @@ -module Interventions - class WorkingDurationService - attr_reader :intervention, :participations, :participation, :product - - def initialize(intervention: nil, participations: [], participation: nil, product: nil) - @intervention = intervention - @participations = participations - @participation = participation - @product = product - end - - def perform(nature: nil, not_nature: nil) - return intervention_working_duration if @participations.empty? && @participation.nil? - - return worker_working_duration(nature) if worker? - - times = workers_times(nature: nature, not_nature: not_nature) - - if times == 0 || - (tractors_count == 0 && prepelled_equipments_count == 0 && tools_count == 0) - return @intervention.working_duration - end - - if tool? - return times.to_d / tools_count - end - - times.to_d / (tractors_count + prepelled_equipments_count) - end - - - private - - def worker_working_duration(nature) - duration = if nature.nil? - @participation - .working_periods - .map(&:duration) - .inject(0, :+) - else - @participation - .working_periods - .select{ |working_period| working_period.nature.to_sym == nature } - .map(&:duration) - .inject(0, :+) - end - - duration.to_d / 3600 - end - - def intervention_working_duration - @intervention.working_duration.to_d / 3600 - end - - def worker? - @product.is_a?(Worker) - end - - def tractor? - @product.is_a?(Equipment) && @product.try(:tractor?) - end - - def self_prepelled_equipment? - @product.variety.to_sym == :self_prepelled_equipment - end - - def tool? - @product.is_a?(Equipment) && product.try(:tractor?) == false - end - - def tractors_count - count = @participations - .select{ |participation| participation.product.try(:tractor?) } - .size - - if tractor? && !product_participation? - count += 1 - end - - count - end - - def tools_count - count = @participations - .select{ |participation| participation.product.is_a?(Equipment) && participation.product.try(:tractor?) == false } - .size - - if !tractor? && tool? && !product_participation? - count += 1 - end - - count - end - - def product_participation? - @participations - .select{ |participation| participation.product == @product } - .present? - end - - def prepelled_equipments_count - @participations - .select{ |participation| participation.product.variety.to_sym == :self_prepelled_equipment } - .size - end - - def workers_times(nature: nil, not_nature: nil) - worker_working_periods(nature, not_nature) - .map(&:duration_gap) - .reduce(0, :+) - end - - def worker_working_periods(nature, not_nature) - participations = @participations.select{ |participation| participation.product.is_a?(Worker) } - working_periods = nil - - if nature.nil? && not_nature.nil? - return participations.map(&:working_periods).flatten - end - - unless nature.nil? - return working_periods_of_nature(participations, nature) - end - - working_periods_not_nature(participations, nature) - end - - def working_periods_of_nature(participations, nature, reverse_result: false) - participations.map do |participation| - participation.working_periods.select do |working_period| - if reverse_result == false - working_period.nature.to_sym == nature - else - working_period.nature.to_sym != nature - end - end - end.flatten - end - - def working_periods_not_nature(participations, nature) - working_periods_of_nature(participations, nature, reverse_result: true) - end - end -end \ No newline at end of file diff --git a/test/services/intervention/working_duration_service_test.rb b/test/services/intervention/working_duration_service_test.rb deleted file mode 100644 index d29fdc498b..0000000000 --- a/test/services/intervention/working_duration_service_test.rb +++ /dev/null @@ -1,282 +0,0 @@ -require 'test_helper' - -module Interventions - class WorkingDurationServiceTest < ActiveSupport::TestCase - setup do - @now = Time.zone.now - - create_workers - create_equipments - create_intervention - create_participations - - @intervention.reload - end - - test 'no participations return intervention working period' do - duration = Interventions::WorkingDurationService - .new(**working_duration_params) - .perform(nature: :intervention) - - assert_equal duration, (@intervention.working_duration / 3600).to_d - end - - test 'no nature specified return sum of working periods for worker' do - working_params = working_duration_params(participation: @alice_participation, - product: @alice) - - duration = Interventions::WorkingDurationService - .new(working_params) - .perform - - sum_working_periods = @alice_participation - .working_periods - .map(&:duration) - .inject(0, :+) - .to_d - - assert_equal duration, (sum_working_periods / 3600).to_d - end - - test 'return sum of specified nature working periods for worker' do - working_params = working_duration_params(participation: @alice_participation, - product: @alice) - - intervention_duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :intervention) - - sum_working_periods = sum_working_periods_of(participation: @alice_participation, nature: :intervention) - - assert_equal intervention_duration, (sum_working_periods.to_d / 3600).to_d - - travel_duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :travel) - - sum_working_periods = sum_working_periods_of(participation: @alice_participation, nature: :travel) - - assert_equal travel_duration, (sum_working_periods.to_d / 3600).to_d - end - - test 'tool working duration without any tractors or tools return intervention working duration' do - working_params = working_duration_params(participations: @participations, - product: Plant.first) - - duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :intervention) - - assert_equal duration, @intervention.working_duration - end - - test 'test tractor calculated working duration' do - working_params = working_duration_params(participations: @participations, - product: @tractor) - - intervention_duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :intervention) - - sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) - - assert_equal intervention_duration, (sum_working_periods.to_d / 1).to_d - - travel_duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :travel) - - sum_working_periods = sum_working_periods_of(participations: @participations, nature: :travel) - - assert_equal travel_duration, (sum_working_periods.to_d / 1).to_d - end - - test 'divise calculated working duration by two if they have two tractors' do - working_params = working_duration_params(participations: @participations, - product: @tractor) - - intervention_duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :intervention) - - sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) - - @participations << @second_tractor_participation - - working_params = working_duration_params(participations: @participations, - product: @tractor) - - intervention_duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :intervention) - - assert_equal (sum_working_periods / 2).to_d.round(2), intervention_duration.round(2) - end - - test 'test tool calculated working duration' do - working_params = working_duration_params(participations: @participations, - product: @tool) - - intervention_duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :intervention) - - sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) - - assert_equal intervention_duration, (sum_working_periods.to_d / 1).to_d - - travel_duration = Interventions::WorkingDurationService - .new(working_params) - .perform(nature: :travel) - - sum_working_periods = sum_working_periods_of(participations: @participations, nature: :travel) - - assert_equal travel_duration, (sum_working_periods.to_d / 1).to_d - end - - private - - def sum_working_periods_of(participation: nil, participations: {}, nature: nil) - unless participations.empty? - return participations - .map(&:working_periods) - .flatten - .select{ |working_period| working_period.nature == nature } - .map(&:duration_gap) - .inject(0, :+) - end - - participation - .working_periods - .select{ |working_period| working_period.nature.to_sym == nature } - .map(&:duration) - .inject(0, :+) - end - - def working_duration_params(participations: {}, participation: nil, product: nil) - unless participations.empty? - return { intervention: @intervention, - participations: participations, - product: product } - end - - { intervention: @intervention, - participation: participation, - product: product } - end - - def fake_working_periods - now = Time.zone.now - [ - InterventionWorkingPeriod.new(started_at: now - 3.hours, stopped_at: now - 2.hours, nature: 'preparation'), - InterventionWorkingPeriod.new(started_at: now - 2.hours, stopped_at: now - 90.minutes, nature: 'travel'), - InterventionWorkingPeriod.new(started_at: now - 90.minutes, stopped_at: now - 30.minutes, nature: 'intervention'), - InterventionWorkingPeriod.new(started_at: now - 30.minutes, stopped_at: now, nature: 'travel') - ] - end - - def create_workers - @alice = Worker.create!( - name: 'Alice', - variety: 'worker', - variant: ProductNatureVariant.first, - person: Entity.contacts.first - ) - - @john = Worker.create!( - name: 'John', - variety: 'worker', - variant: ProductNatureVariant.first, - person: Entity.contacts.last - ) - end - - def create_equipments - @tractor = Equipment.create!( - name: "Fake tractor", - variety: 'tractor', - variant: ProductNatureVariant.where(variety: 'tractor').first - ) - - @second_tractor = Equipment.create!( - name: "Fake second tractor", - variety: 'tractor', - variant: ProductNatureVariant.where(variety: 'tractor').first - ) - - @tool = Equipment.create!( - name: "Fake seeder", - variety: 'trailed_equipment', - variant: ProductNatureVariant.where(variety: 'trailed_equipment').first - ) - end - - def create_intervention - @intervention = Intervention.create!( - procedure_name: :sowing, - actions: [:sowing], - request_compliant: false, - working_periods: fake_working_periods - ) - - @intervention.doers.create!( - product: @alice, - reference_name: 'land_parcel' - ) - - @intervention.doers.create!( - product: @john, - reference_name: 'land_parcel' - ) - end - - def create_participations - @alice_participation = InterventionParticipation.create!( - state: :done, - request_compliant: false, - procedure_name: :sowing, - product: @alice, - working_periods_attributes: [ - { - started_at: @now - 1.hour, - stopped_at: @now - 30.minutes, - nature: 'travel' - }, - { - started_at: @now - 30.minutes, - stopped_at: @now - 15.minutes, - nature: 'intervention' - }, - { - started_at: @now - 10.minutes, - stopped_at: @now, - nature: 'intervention' - } - ] - ) - - @john_participation = InterventionParticipation.create!( - state: :done, - request_compliant: false, - procedure_name: :sowing, - product: @john, - working_periods_attributes: [ - { - started_at: @now - 1.hour, - stopped_at: @now, - nature: 'intervention' - } - ] - ) - - @second_tractor_participation = InterventionParticipation.create!( - state: :done, - request_compliant: false, - procedure_name: :sowing, - product: @second_tractor - ) - - @participations = [@alice_participation, @john_participation] - end - end -end \ No newline at end of file diff --git a/test/services/intervention_working_time_duration_calculation_service_test.rb b/test/services/intervention_working_time_duration_calculation_service_test.rb new file mode 100644 index 0000000000..3053b2c83e --- /dev/null +++ b/test/services/intervention_working_time_duration_calculation_service_test.rb @@ -0,0 +1,280 @@ +require 'test_helper' + +class InterventionWorkingTimeDurationCalculationServiceTest < ActiveSupport::TestCase + setup do + @now = Time.zone.now + + create_workers + create_equipments + create_intervention + create_participations + + @intervention.reload + end + + test 'no participations return intervention working period' do + duration = InterventionWorkingTimeDurationCalculationService + .new(**working_duration_params) + .perform(nature: :intervention) + + assert_equal duration, (@intervention.working_duration / 3600).to_d + end + + test 'no nature specified return sum of working periods for worker' do + working_params = working_duration_params(participation: @alice_participation, + product: @alice) + + duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform + + sum_working_periods = @alice_participation + .working_periods + .map(&:duration) + .inject(0, :+) + .to_d + + assert_equal duration, (sum_working_periods / 3600).to_d + end + + test 'return sum of specified nature working periods for worker' do + working_params = working_duration_params(participation: @alice_participation, + product: @alice) + + intervention_duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :intervention) + + sum_working_periods = sum_working_periods_of(participation: @alice_participation, nature: :intervention) + + assert_equal intervention_duration, (sum_working_periods.to_d / 3600).to_d + + travel_duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :travel) + + sum_working_periods = sum_working_periods_of(participation: @alice_participation, nature: :travel) + + assert_equal travel_duration, (sum_working_periods.to_d / 3600).to_d + end + + test 'tool working duration without any tractors or tools return intervention working duration' do + working_params = working_duration_params(participations: @participations, + product: Plant.first) + + duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :intervention) + + assert_equal duration, @intervention.working_duration + end + + test 'test tractor calculated working duration' do + working_params = working_duration_params(participations: @participations, + product: @tractor) + + intervention_duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :intervention) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) + + assert_equal intervention_duration, (sum_working_periods.to_d / 1).to_d + + travel_duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :travel) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :travel) + + assert_equal travel_duration, (sum_working_periods.to_d / 1).to_d + end + + test 'divise calculated working duration by two if they have two tractors' do + working_params = working_duration_params(participations: @participations, + product: @tractor) + + intervention_duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :intervention) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) + + @participations << @second_tractor_participation + + working_params = working_duration_params(participations: @participations, + product: @tractor) + + intervention_duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :intervention) + + assert_equal (sum_working_periods / 2).to_d.round(2), intervention_duration.round(2) + end + + test 'test tool calculated working duration' do + working_params = working_duration_params(participations: @participations, + product: @tool) + + intervention_duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :intervention) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :intervention) + + assert_equal intervention_duration, (sum_working_periods.to_d / 1).to_d + + travel_duration = InterventionWorkingTimeDurationCalculationService + .new(working_params) + .perform(nature: :travel) + + sum_working_periods = sum_working_periods_of(participations: @participations, nature: :travel) + + assert_equal travel_duration, (sum_working_periods.to_d / 1).to_d + end + + private + + def sum_working_periods_of(participation: nil, participations: {}, nature: nil) + unless participations.empty? + return participations + .map(&:working_periods) + .flatten + .select { |working_period| working_period.nature == nature } + .map(&:duration_gap) + .inject(0, :+) + end + + participation + .working_periods + .select { |working_period| working_period.nature.to_sym == nature } + .map(&:duration) + .inject(0, :+) + end + + def working_duration_params(participations: {}, participation: nil, product: nil) + unless participations.empty? + return { intervention: @intervention, + participations: participations, + product: product } + end + + { intervention: @intervention, + participation: participation, + product: product } + end + + def fake_working_periods + now = Time.zone.now + [ + InterventionWorkingPeriod.new(started_at: now - 3.hours, stopped_at: now - 2.hours, nature: 'preparation'), + InterventionWorkingPeriod.new(started_at: now - 2.hours, stopped_at: now - 90.minutes, nature: 'travel'), + InterventionWorkingPeriod.new(started_at: now - 90.minutes, stopped_at: now - 30.minutes, nature: 'intervention'), + InterventionWorkingPeriod.new(started_at: now - 30.minutes, stopped_at: now, nature: 'travel') + ] + end + + def create_workers + @alice = Worker.create!( + name: 'Alice', + variety: 'worker', + variant: ProductNatureVariant.first, + person: Entity.contacts.first + ) + + @john = Worker.create!( + name: 'John', + variety: 'worker', + variant: ProductNatureVariant.first, + person: Entity.contacts.last + ) + end + + def create_equipments + @tractor = Equipment.create!( + name: 'Fake tractor', + variety: 'tractor', + variant: ProductNatureVariant.where(variety: 'tractor').first + ) + + @second_tractor = Equipment.create!( + name: 'Fake second tractor', + variety: 'tractor', + variant: ProductNatureVariant.where(variety: 'tractor').first + ) + + @tool = Equipment.create!( + name: 'Fake seeder', + variety: 'trailed_equipment', + variant: ProductNatureVariant.where(variety: 'trailed_equipment').first + ) + end + + def create_intervention + @intervention = Intervention.create!( + procedure_name: :sowing, + actions: [:sowing], + request_compliant: false, + working_periods: fake_working_periods + ) + + @intervention.doers.create!( + product: @alice, + reference_name: 'land_parcel' + ) + + @intervention.doers.create!( + product: @john, + reference_name: 'land_parcel' + ) + end + + def create_participations + @alice_participation = InterventionParticipation.create!( + state: :done, + request_compliant: false, + procedure_name: :sowing, + product: @alice, + working_periods_attributes: [ + { + started_at: @now - 1.hour, + stopped_at: @now - 30.minutes, + nature: 'travel' + }, + { + started_at: @now - 30.minutes, + stopped_at: @now - 15.minutes, + nature: 'intervention' + }, + { + started_at: @now - 10.minutes, + stopped_at: @now, + nature: 'intervention' + } + ] + ) + + @john_participation = InterventionParticipation.create!( + state: :done, + request_compliant: false, + procedure_name: :sowing, + product: @john, + working_periods_attributes: [ + { + started_at: @now - 1.hour, + stopped_at: @now, + nature: 'intervention' + } + ] + ) + + @second_tractor_participation = InterventionParticipation.create!( + state: :done, + request_compliant: false, + procedure_name: :sowing, + product: @second_tractor + ) + + @participations = [@alice_participation, @john_participation] + end +end From 2e2b6a6a7142b3e7d9099c8a67f3ec53e0f5af44 Mon Sep 17 00:00:00 2001 From: Brice TEXIER Date: Fri, 11 Aug 2017 19:00:50 +0200 Subject: [PATCH 32/38] Sync Gemfile with master --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ca1d0e6eab..429c210db9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,7 +65,7 @@ GEM sidekiq (>= 2.11) arel (6.0.4) ast (2.3.0) - autoprefixer-rails (7.1.2.4) + autoprefixer-rails (7.1.2.3) execjs awesome_nested_set (3.1.3) activerecord (>= 4.0.0, < 5.2) @@ -94,7 +94,7 @@ GEM railties (>= 3.2, < 6.0) bootstrap3-datetimepicker-rails (4.17.47) momentjs-rails (>= 2.8.1) - browser (2.5.0) + browser (2.4.0) builder (3.2.3) bullet (5.5.1) activesupport (>= 3.0.0) @@ -456,7 +456,7 @@ GEM selenium-webdriver (3.4.4) childprocess (~> 0.5) rubyzip (~> 1.0) - sentry-raven (2.6.3) + sentry-raven (2.6.2) faraday (>= 0.7.6, < 1.0) sepa_king (0.9.0) activemodel (>= 3.0.0) From 09f36aa39065c7349ef566bcb62dae39f03fc109 Mon Sep 17 00:00:00 2001 From: Brice TEXIER Date: Fri, 11 Aug 2017 19:01:25 +0200 Subject: [PATCH 33/38] Cleans code with Rubocop --- .../intervention_participations_controller.rb | 14 +++++++------- app/models/intervention_agent.rb | 12 ++++++------ ...ervention_participations_controller_test.rb | 18 +++++++++--------- test/models/intervention_participation_test.rb | 1 - 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index d347c71ac5..e618eabaca 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -114,7 +114,7 @@ def calculate_working_periods auto_calcul_mode = params[:auto_calcul_mode] return [] if auto_calcul_mode.to_sym == :false || - participations.blank? || tool.nil? + participations.blank? || tool.nil? working_periods = [] working_duration_params = { intervention: @intervention, @@ -125,16 +125,16 @@ def calculate_working_periods natures = %i[intervention] unless tool.try(:tractor?) natures.each do |nature| - duration = Interventions::WorkingDurationService - .new(**working_duration_params) - .perform(nature: nature) + duration = InterventionWorkingTimeDurationCalculationService + .new(**working_duration_params) + .perform(nature: nature) stopped_at = intervention_started_at + (duration * 60 * 60) working_periods << InterventionWorkingPeriod - .new(nature: nature, - started_at: intervention_started_at, - stopped_at: stopped_at) + .new(nature: nature, + started_at: intervention_started_at, + stopped_at: stopped_at) end working_periods diff --git a/app/models/intervention_agent.rb b/app/models/intervention_agent.rb index fb498d27a9..51af6efc52 100644 --- a/app/models/intervention_agent.rb +++ b/app/models/intervention_agent.rb @@ -73,11 +73,11 @@ def participation def cost_amount_computation(nature: nil, natures: {}) return InterventionParameter::AmountComputation.failed unless product - if natures.empty? - quantity = nature_quantity(nature) - else - quantity = natures_quantity(natures) - end + quantity = if natures.empty? + nature_quantity(nature) + else + natures_quantity(natures) + end unit_name = Nomen::Unit.find(:hour).human_name unit_name = unit_name.pluralize if quantity > 1 @@ -109,7 +109,7 @@ def natures_quantity(natures) end def nature_quantity(nature) - Interventions::WorkingDurationService + InterventionWorkingTimeDurationCalculationService .new(**working_duration_params) .perform(nature: nature) end diff --git a/test/controllers/api/v1/intervention_participations_controller_test.rb b/test/controllers/api/v1/intervention_participations_controller_test.rb index d8ef0ca64e..a33468280b 100644 --- a/test/controllers/api/v1/intervention_participations_controller_test.rb +++ b/test/controllers/api/v1/intervention_participations_controller_test.rb @@ -81,19 +81,19 @@ class InterventionParticipationsControllerTest < ActionController::TestCase test 'ignores overlapping working periods' do add_auth_header - payload = overlapping_payload + payload = overlapping_payload - part_id = JSON(post(:create, payload).body)['id'] - original_count = InterventionParticipation.find(part_id).working_periods.count + part_id = JSON(post(:create, payload).body)['id'] + original_count = InterventionParticipation.find(part_id).working_periods.count - assert_equal 1, original_count + assert_equal 1, original_count - payload = overlapping_payload(only_overlap: true) - part_id = JSON(post(:create, payload).body)['id'] - new_count = InterventionParticipation.find(part_id).working_periods.count + payload = overlapping_payload(only_overlap: true) + part_id = JSON(post(:create, payload).body)['id'] + new_count = InterventionParticipation.find(part_id).working_periods.count - assert_equal original_count, new_count - end + assert_equal original_count, new_count + end test 'created working_periods have the correct nature' do add_auth_header diff --git a/test/models/intervention_participation_test.rb b/test/models/intervention_participation_test.rb index f93ecace32..5b2ef56f86 100644 --- a/test/models/intervention_participation_test.rb +++ b/test/models/intervention_participation_test.rb @@ -152,7 +152,6 @@ class InterventionParticipationTest < ActiveSupport::TestCase started_at: now, stopped_at: now + 1.hour ) - assert_raises do @participation.working_periods.create!( nature: :intervention, From 4d47b8c1af5f2648840409228e2ae93eb09374dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 17 Aug 2017 10:08:52 +0200 Subject: [PATCH 34/38] Correct intervention participations convert tests --- .../backend/intervention_participations_controller.rb | 8 ++++++-- .../_participations_modal.html.haml | 4 ++-- config/routes.rb | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/backend/intervention_participations_controller.rb b/app/controllers/backend/intervention_participations_controller.rb index e618eabaca..8e3440eb5f 100644 --- a/app/controllers/backend/intervention_participations_controller.rb +++ b/app/controllers/backend/intervention_participations_controller.rb @@ -95,6 +95,8 @@ def form_participations end def intervention_tool + return nil if params[:product_id].nil? + product = Product.find(params[:product_id]) return nil unless product.is_a?(Equipment) @@ -105,7 +107,8 @@ def intervention_tool def intervention_started_at return @intervention.started_at unless @intervention.nil? - Time.parse(params['intervention_started_at']) + Time.parse(params['intervention_started_at']) if params['intervention_started_at'].present? + Time.now end def calculate_working_periods @@ -113,7 +116,8 @@ def calculate_working_periods tool = intervention_tool auto_calcul_mode = params[:auto_calcul_mode] - return [] if auto_calcul_mode.to_sym == :false || + return [] if !auto_calcul_mode.nil? && + auto_calcul_mode.to_sym == :false || participations.blank? || tool.nil? working_periods = [] diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index d2abfa941d..583ba333f3 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -21,7 +21,7 @@ %h3{ class: "action-header" }= :calculated_hours.tl - - if auto_calcul_mode.to_sym == :true && !calculate_working_periods.blank? + - if !auto_calcul_mode.nil? && auto_calcul_mode.to_sym == :true && !calculate_working_periods.blank? - calculate_working_periods.each do |calculate_working_period| = render 'working_periods_fields', { working_period: calculate_working_period } @@ -55,7 +55,7 @@ - classes = 'hidden' unless tool.nil? %div{ class: "auto-calculate-equipments #{ classes }"} - = check_box 'participation', "auto_calculate_equipments", checked: auto_calcul_mode.to_sym == :true + = check_box 'participation', "auto_calculate_equipments", checked: !auto_calcul_mode.nil? && auto_calcul_mode.to_sym == :true %span Mode de calcul automatique %p En mode automatique, les périodes de déplacement et d'intervention des tracteurs et outils seront calculés à partir de la moyenne des périodes des opérateurs. diff --git a/config/routes.rb b/config/routes.rb index 30535d04a5..ad50ea9649 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -594,6 +594,9 @@ collection do get :participations_modal end + member do + post :convert + end end resources :inventories, concerns: %i[list unroll] do From 963558fcce34ec03229929b67b29dd04f7bdc769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 17 Aug 2017 11:52:22 +0200 Subject: [PATCH 35/38] Change 'horarie' label (oops) --- config/locales/fra/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/fra/action.yml b/config/locales/fra/action.yml index bd8e0d182d..28a804589a 100644 --- a/config/locales/fra/action.yml +++ b/config/locales/fra/action.yml @@ -1015,7 +1015,7 @@ fra: buildings_map: "Carte des bâtiments" #? by_year: "Par an" calculate: "Calculer" - calculated_hours: "Horaries calculées" + calculated_hours: "Horaires calculées" calculators: "Calculateurs" calendar: "Calendrier" campaign: "Campagne" From 045a81a88d7232cc70d6b597fb5fad09af393890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20L=C3=A9cuelle?= Date: Thu, 17 Aug 2017 18:32:58 +0200 Subject: [PATCH 36/38] Hidden tools and tractors dates --- .../backend/intervention_participations.js.coffee | 12 +++++++++--- .../_participations_modal.html.haml | 6 +++--- .../_working_periods_fields.html.haml | 8 +++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/backend/intervention_participations.js.coffee b/app/assets/javascripts/backend/intervention_participations.js.coffee index f3ebc24edf..cda8f1a227 100644 --- a/app/assets/javascripts/backend/intervention_participations.js.coffee +++ b/app/assets/javascripts/backend/intervention_participations.js.coffee @@ -48,10 +48,16 @@ $(min_field).append('Min') $(newLine).find('.participation-form').append(min_field) + classes = "" + if $('#intervention_tool').val() == "true" + classes = "hidden" + participationResult = $('
') - $(participationResult).append('') - $(participationResult).append('') - $(participationResult).append('') + results = $('
') + $(results).append('') + $(results).append('') + $(results).append('') + $(participationResult).append(results) $(newLine).append(participationResult) clearPeriod = $('
') diff --git a/app/views/backend/intervention_participations/_participations_modal.html.haml b/app/views/backend/intervention_participations/_participations_modal.html.haml index 583ba333f3..0628457bdc 100644 --- a/app/views/backend/intervention_participations/_participations_modal.html.haml +++ b/app/views/backend/intervention_participations/_participations_modal.html.haml @@ -23,17 +23,17 @@ - if !auto_calcul_mode.nil? && auto_calcul_mode.to_sym == :true && !calculate_working_periods.blank? - calculate_working_periods.each do |calculate_working_period| - = render 'working_periods_fields', { working_period: calculate_working_period } + = render 'working_periods_fields', { working_period: calculate_working_period, tool: tool } - elsif !participation.nil? - participation.working_periods.each do |working_period| - = render 'working_periods_fields', { working_period: working_period } + = render 'working_periods_fields', { working_period: working_period, tool: tool } - if working_period.pause_next? - pause_period = InterventionWorkingPeriod.new(nature: :pause, started_at: working_period.stopped_at, stopped_at: working_period.next_period.started_at) - = render 'working_periods_fields', { working_period: pause_period } + = render 'working_periods_fields', { working_period: pause_period, tool: tool } .actions diff --git a/app/views/backend/intervention_participations/_working_periods_fields.html.haml b/app/views/backend/intervention_participations/_working_periods_fields.html.haml index 7cb64fec9a..ee718d242f 100644 --- a/app/views/backend/intervention_participations/_working_periods_fields.html.haml +++ b/app/views/backend/intervention_participations/_working_periods_fields.html.haml @@ -22,10 +22,12 @@ = text_field_tag "working_period_minutes", working_period.minutes_gap, { class: "participation-input", data: { 'is-minutes-field': true }} %span= t('labels.minutes') + - classes = "hidden" unless tool.nil? .participation-result - %span{ class: "previous-working-date" }= working_period.started_at.l(format: :full) - %span → - %span{ class: "next-working-date" }= working_period.stopped_at.l(format: :full) + %div{ class: "results #{classes}"} + %span{ class: "previous-working-date" }= working_period.started_at.l(format: :full) + %span → + %span{ class: "next-working-date" }= working_period.stopped_at.l(format: :full) .clear-period %i.picto.picto-clear From 8edae85dc8a8f1ac44616e429b9b98c6862fadce Mon Sep 17 00:00:00 2001 From: David JOULIN Date: Thu, 17 Aug 2017 19:45:32 +0200 Subject: [PATCH 37/38] Remove times details to avoid to many mistakes about time interpretation. --- app/views/backend/interventions/show.html.haml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/backend/interventions/show.html.haml b/app/views/backend/interventions/show.html.haml index 6445e55bd8..3e127f9862 100644 --- a/app/views/backend/interventions/show.html.haml +++ b/app/views/backend/interventions/show.html.haml @@ -68,9 +68,14 @@ - c.cobble(:general_informations) do = infos do - .med-info.important + -#.med-info.important %span.title= Intervention.human_attribute_name(:nature) %span.value= resource.nature.l #lights(resource.status) + .med-info + %span.title= Intervention.human_attribute_name(:started_at) + %span.value + %i.picto.picto-calendar + = resource.started_at.l .med-info %span.title= Intervention.human_attribute_name(:working_duration) %span.value @@ -81,17 +86,17 @@ %span.value %i.picto.picto-timelapse = human_duration(resource.drivers_times(nature: nil)) - .med-info + -#.med-info %span.title= I18n.t('enumerize.intervention_working_period.nature.preparation') %span.value %i.picto.picto-clock-o = human_duration(resource.drivers_times(nature: :preparation)) - .med-info + -#.med-info %span.title= I18n.t('enumerize.intervention_working_period.nature.travel') %span.value %i.picto.picto-clock-o = human_duration(resource.drivers_times(nature: :travel)) - .med-info + -#.med-info %span.title= I18n.t('enumerize.intervention_working_period.nature.intervention') %span.value %i.picto.picto-clock-o From a8dd28df9da38274dbb46995b104a2395916b830 Mon Sep 17 00:00:00 2001 From: David JOULIN Date: Thu, 17 Aug 2017 19:46:07 +0200 Subject: [PATCH 38/38] Make tractor filter more suitable to avoid to many equipment proposition --- config/procedures/hoeing.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/procedures/hoeing.xml b/config/procedures/hoeing.xml index 0584b34e66..827e4e892d 100644 --- a/config/procedures/hoeing.xml +++ b/config/procedures/hoeing.xml @@ -6,7 +6,7 @@ - +