From 2ce64698865a011632647ee937efb89bea74afa4 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Fri, 10 Mar 2023 15:07:51 +0100 Subject: [PATCH] orga edition --- app/views/extranet/account/show.html.erb | 4 +- .../extranet/alumni/persons/_path.html.erb | 34 ----- .../extranet/alumni/persons/show.html.erb | 32 +++- .../extranet/contacts/persons/show.html.erb | 2 +- .../extranet/experiences/_experience.html.erb | 8 +- app/views/extranet/experiences/_form.html.erb | 48 +++--- app/views/extranet/experiences/_list.html.erb | 12 ++ .../extranet/organizations/show.html.erb | 140 ++++++++++-------- .../_details.html.erb | 0 9 files changed, 152 insertions(+), 128 deletions(-) delete mode 100644 app/views/extranet/alumni/persons/_path.html.erb create mode 100644 app/views/extranet/experiences/_list.html.erb rename app/views/extranet/{alumni/persons => personal_data}/_details.html.erb (100%) diff --git a/app/views/extranet/account/show.html.erb b/app/views/extranet/account/show.html.erb index cb79fe1a1..d36d78bad 100644 --- a/app/views/extranet/account/show.html.erb +++ b/app/views/extranet/account/show.html.erb @@ -11,7 +11,7 @@ <%= link_to University::Person::Experience.human_attribute_name('new'), new_experience_path, class: 'btn btn-sm btn-primary mt-md-n5 float-md-end' %> - <%= render 'extranet/alumni/persons/path', person: @person, edit: true %> + <%= render 'extranet/experiences/list', person: @person, edit: true %> </div> <div class="col-md-3"> <%= kamifusen_tag @person.best_picture, width: 400, class: 'img-fluid person__portrait' if @person&.best_picture&.attached? %> @@ -19,6 +19,6 @@ <%= link_to t('extranet.account.edit'), edit_account_path, class: 'btn btn-primary mb-2' %> <%= link_to t('extranet.account.edit_personal_data'), edit_personal_data_path, class: 'btn btn-primary mb-2' %> </div> - <%= render 'extranet/alumni/persons/details', person: @person unless @person.nil? %> + <%= render 'extranet/personal_data/details', person: @person unless @person.nil? %> </div> </div> diff --git a/app/views/extranet/alumni/persons/_path.html.erb b/app/views/extranet/alumni/persons/_path.html.erb deleted file mode 100644 index 4572ea2b2..000000000 --- a/app/views/extranet/alumni/persons/_path.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -<% -edit ||= false -%> -<div class="experiences mt-4"> - <ul class="list-unstyled"> - <% if person&.experiences&.any? %> - <% @person.experiences.ordered.each do |experience| %> - <%= render 'extranet/experiences/experience', experience: experience, edit: edit %> - <% end %> - <% end %> - <% person&.cohorts&.each do |cohort| %> - <li class="experiences__experience py-4 border-top"> - <div class="row"> - <div class="col-md-6"> - <p class="mb-0"> - <%= link_to [:alumni, cohort] do %> - <b><%= cohort.program %></b><br> - <%= cohort.program.diploma %><br> - <%= cohort.year %> - <% end %> - </p> - </div> - <div class="col-md-6 text-end"> - <% if cohort.school.logo.attached? %> - <%= kamifusen_tag cohort.school.logo, width: 100, class: 'img-fluid experience__organization__logo' %> - <% else %> - <p class="text-end"><%= cohort.school %></p> - <% end %> - </div> - </div> - </li> - <% end %> - </ul> -</div> diff --git a/app/views/extranet/alumni/persons/show.html.erb b/app/views/extranet/alumni/persons/show.html.erb index 6079d71e1..b3c9d0fca 100644 --- a/app/views/extranet/alumni/persons/show.html.erb +++ b/app/views/extranet/alumni/persons/show.html.erb @@ -12,10 +12,38 @@ </div> </div> <p class="mb-4"><%= t('extranet.experiences.title') %></p> - <%= render 'extranet/alumni/persons/path', person: @person %> + <%= render 'extranet/experiences/list', person: @person %> + + <div class="experiences mt-4"> + <ul class="list-unstyled"> + <% person&.cohorts&.each do |cohort| %> + <li class="experiences__experience py-4 border-top"> + <div class="row"> + <div class="col-md-6"> + <p class="mb-0"> + <%= link_to [:alumni, cohort] do %> + <b><%= cohort.program %></b><br> + <%= cohort.program.diploma %><br> + <%= cohort.year %> + <% end %> + </p> + </div> + <div class="col-md-6 text-end"> + <% if cohort.school.logo.attached? %> + <%= kamifusen_tag cohort.school.logo, width: 100, class: 'img-fluid experience__organization__logo' %> + <% else %> + <p class="text-end"><%= cohort.school %></p> + <% end %> + </div> + </div> + </li> + <% end %> + </ul> + </div> + </div> <div class="offset-md-1 col-md-3 order-1 order-md-2"> <%= kamifusen_tag @person.best_picture, width: 400, class: 'img-fluid person__portrait' if @person.best_picture.attached? %> - <%= render 'extranet/alumni/persons/details', person: @person %> + <%= render 'extranet/personal_data/details', person: @person %> </div> </div> diff --git a/app/views/extranet/contacts/persons/show.html.erb b/app/views/extranet/contacts/persons/show.html.erb index 36302396a..7c73b06e6 100644 --- a/app/views/extranet/contacts/persons/show.html.erb +++ b/app/views/extranet/contacts/persons/show.html.erb @@ -19,6 +19,6 @@ </div> <div class="offset-md-1 col-md-3 order-1 order-md-2"> <%= kamifusen_tag @person.best_picture, width: 400, class: 'img-fluid person__portrait' if @person.best_picture.attached? %> - <%= render 'extranet/alumni/persons/details', person: @person %> + <%= render 'extranet/personal_data/details', person: @person %> </div> </div> diff --git a/app/views/extranet/experiences/_experience.html.erb b/app/views/extranet/experiences/_experience.html.erb index e5f211fc6..4db5233f7 100644 --- a/app/views/extranet/experiences/_experience.html.erb +++ b/app/views/extranet/experiences/_experience.html.erb @@ -15,12 +15,12 @@ edit ||= false </div> <div class="col-md-6 text-end"> <% if experience.organization.present? %> - <%= link_to [:alumni, experience.organization] do %> - <% if experience.organization.logo.attached? %> + <% if experience.organization.logo.attached? %> + <%= link_to organization_path(experience.organization) do %> <%= kamifusen_tag experience.organization.logo, width: 100, class: 'img-fluid experience__organization__logo' %> - <% else %> - <p class="text-end><%= link_to experience.organization, [:alumni, experience.organization] %></p> <% end %> + <% else %> + <p class="text-end><%= link_to experience.organization, organization_path(experience.organization) %></p> <% end %> <div> <% end %> diff --git a/app/views/extranet/experiences/_form.html.erb b/app/views/extranet/experiences/_form.html.erb index 905e10aff..1773637db 100644 --- a/app/views/extranet/experiences/_form.html.erb +++ b/app/views/extranet/experiences/_form.html.erb @@ -2,7 +2,29 @@ <div class="row"> <div class="col-lg-6"> - <%= f.input :description, as: :string %> + <%= f.input :organization_name, + label: University::Organization.model_name.human, + as: :autocomplete, + required: true, + url: search_organizations_path, + placeholder: t("extranet.experiences.search_organization"), + input_html: { + data: { + "showNoMatches": "false", + "autocomplete-target": "#university_person_experience_organization_id", + "autocomplete-no-result-target": "#university_person_experience_organization_not_found" + }, + autocomplete: 'off', + role: 'presentation' + } %> + <%= f.hidden_field :organization_id %> + <div class="<%= 'd-none' unless experience.organization_id.nil? && experience.organization_name.present? %>" id="university_person_experience_organization_not_found" data-default-text="<%= t('extranet.account.experiences.create_new_html', name: 'CHANGEME', url: new_organization_path(name: 'CHANGEME')) %>"> + <% if experience.organization_id.nil? && experience.organization_name.present? %> + <%= t('extranet.account.experiences.create_new_html', name: experience.organization_name, url: new_organization_path(name: experience.organization_name)) %> + <% end %> + </div> + </div> + <div class="col-lg-6"> <div class="row"> <div class="col-6"> <%= f.input :from_year %> @@ -11,29 +33,7 @@ <%= f.input :to_year %> </div> </div> - </div> - <div class="col-lg-6"> - <%= f.input :organization_name, - label: University::Organization.model_name.human, - as: :autocomplete, - required: true, - url: search_organizations_path, - placeholder: t("extranet.experiences.search_organization"), - input_html: { - data: { - "showNoMatches": "false", - "autocomplete-target": "#university_person_experience_organization_id", - "autocomplete-no-result-target": "#university_person_experience_organization_not_found" - }, - autocomplete: 'off', - role: 'presentation' - } %> - <%= f.hidden_field :organization_id %> - <div class="<%= 'd-none' unless experience.organization_id.nil? && experience.organization_name.present? %>" id="university_person_experience_organization_not_found" data-default-text="<%= t('extranet.account.experiences.create_new_html', name: 'CHANGEME', url: new_organization_path(name: 'CHANGEME')) %>"> - <% if experience.organization_id.nil? && experience.organization_name.present? %> - <%= t('extranet.account.experiences.create_new_html', name: experience.organization_name, url: new_organization_path(name: experience.organization_name)) %> - <% end %> - </div> + <%= f.input :description, as: :string %> </div> </div> <%= submit f %> diff --git a/app/views/extranet/experiences/_list.html.erb b/app/views/extranet/experiences/_list.html.erb new file mode 100644 index 000000000..8873d0a51 --- /dev/null +++ b/app/views/extranet/experiences/_list.html.erb @@ -0,0 +1,12 @@ +<% +edit ||= false +%> +<div class="experiences mt-4"> + <ul class="list-unstyled"> + <% if person&.experiences&.any? %> + <% @person.experiences.ordered.each do |experience| %> + <%= render 'extranet/experiences/experience', experience: experience, edit: edit %> + <% end %> + <% end %> + </ul> +</div> diff --git a/app/views/extranet/organizations/show.html.erb b/app/views/extranet/organizations/show.html.erb index 46228f5a6..0c6394a26 100644 --- a/app/views/extranet/organizations/show.html.erb +++ b/app/views/extranet/organizations/show.html.erb @@ -10,90 +10,108 @@ <h2><%= University::Organization.human_attribute_name('legal') %></h2> <div class="row"> - <div class="col-xxl-6"> - <%= osuny_label University::Organization.human_attribute_name('long_name') %> - <p><%= @organization.long_name %></p> - </div> + <% if @organization.long_name.present? %> + <div class="col-xxl-6"> + <%= osuny_label University::Organization.human_attribute_name('long_name') %> + <p><%= @organization.long_name %></p> + </div> + <% end %> <div class="col-xxl-6"> <%= osuny_label University::Organization.human_attribute_name('kind') %> <p><%= @organization.kind_i18n %></p> </div> - <div class="col-xxl-6"> - <%= osuny_label University::Organization.human_attribute_name('siren') %> - <p><%= @organization.siren %></p> - </div> - </div> - </div> - - <div class="col-md-6"> - <h2><%= University::Organization.human_attribute_name('physical') %> - <div class="row"> - <% [ - :address_name, - :address, - :address_additional, - :zipcode, - :city, - ].each do |property| %> - <% value = @organization.send property %> - <% next if value.blank? %> - <div class="col-xxl-6"> - <%= osuny_label University::Organization.human_attribute_name(property) %> - <p><%= value %></p> - </div> - <% end %> - <% if @organization.country.present? %> - <div class="col-xxl-6"> - <%= osuny_label University::Organization.human_attribute_name('country') %> - <p><%= ISO3166::Country[@organization.country].common_name %></p> - </div> - <% end %> - <% if @organization.geolocated? %> + <% if @organization.siren.present? %> <div class="col-xxl-6"> - <%= osuny_label University::Organization.human_attribute_name('geolocation') %> - <p><%= @organization.geo_point.to_s %></p> + <%= osuny_label University::Organization.human_attribute_name('siren') %> + <p><%= @organization.siren %></p> </div> <% end %> </div> + </div> - <h2><%= University::Organization.human_attribute_name('digital') %></h2> - <div class="row"> - <% unless @organization.url.blank? %> - <div class="col-xxl-6"> - <%= osuny_label University::Organization.human_attribute_name('url') %> - <p><%= link_to @organization.url, - @organization.url, - target: :_blank %></p> - </div> - <% end %> - <% [ - :phone, + <div class="col-md-6"> + <% if @organization.address_name.present? || + @organization.address.present? || + @organization.address_additional.present? || + @organization.zipcode.present? || + @organization.city.present? || + @organization.country.present? || + @organization.geolocated? %> + <h2><%= University::Organization.human_attribute_name('physical') %> + <div class="row"> + <% [ + :address_name, + :address, + :address_additional, + :zipcode, + :city, + ].each do |property| %> + <% value = @organization.send property %> + <% next if value.blank? %> + <div class="col-xxl-6"> + <%= osuny_label University::Organization.human_attribute_name(property) %> + <p><%= value %></p> + </div> + <% end %> + <% if @organization.country.present? %> + <div class="col-xxl-6"> + <%= osuny_label University::Organization.human_attribute_name('country') %> + <p><%= ISO3166::Country[@organization.country].common_name %></p> + </div> + <% end %> + <% if @organization.geolocated? %> + <div class="col-xxl-6"> + <%= osuny_label University::Organization.human_attribute_name('geolocation') %> + <p><%= @organization.geo_point.to_s %></p> + </div> + <% end %> + </div> + <% end %> + + <% if @organization.phone.present? || + @organization.email.present? || + @organization.linkedin.present? || + @organization.twitter.present? || + @organization.mastodon.present? %> + <h2><%= University::Organization.human_attribute_name('digital') %></h2> + <div class="row"> + <% unless @organization.url.blank? %> + <div class="col-xxl-6"> + <%= osuny_label University::Organization.human_attribute_name('url') %> + <p><%= link_to @organization.url, + @organization.url, + target: :_blank %></p> + </div> + <% end %> + <% [ + :phone, :email, :linkedin, :twitter, :mastodon - ].each do |property| %> - <% value = @organization.send property %> - <% next if value.blank? %> - <div class="col-xxl-6"> - <%= osuny_label University::Organization.human_attribute_name(property) %> - <p><%= value %></p> - </div> - <% end %> - </div> + ].each do |property| %> + <% value = @organization.send property %> + <% next if value.blank? %> + <div class="col-xxl-6"> + <%= osuny_label University::Organization.human_attribute_name(property) %> + <p><%= value %></p> + </div> + <% end %> + </div> + <% end %> <% if @organization.logo.attached? || @organization.logo_on_dark_background.attached? %> <h2><%= t('university.organization.logos') %></h2> <% if @organization.logo.attached? %> <%= osuny_label University::Organization.human_attribute_name('logo') %><br> - <%= kamifusen_tag @organization.logo, class: 'img-fluid img-fill bg-light img-thumbnail p-5 mb-3' %> + <%= kamifusen_tag @organization.logo, class: 'img-fluid img-fill bg-light img-thumbnail mb-3' %> <% end %> <% if @organization.logo_on_dark_background.attached? %> <%= osuny_label University::Organization.human_attribute_name('logo_on_dark_background') %><br> - <%= kamifusen_tag @organization.logo_on_dark_background, class: 'img-fluid img-fill bg-dark img-thumbnail p-5' %> + <%= kamifusen_tag @organization.logo_on_dark_background, class: 'img-fluid img-fill bg-dark img-thumbnail' %> <% end %> <% end %> </div> - <%= link_to t('edit'), edit_organization_path(@organization), class: 'btn btn-primary' %> </div> +<%= link_to t('edit'), edit_organization_path(@organization), class: 'btn btn-primary' %> diff --git a/app/views/extranet/alumni/persons/_details.html.erb b/app/views/extranet/personal_data/_details.html.erb similarity index 100% rename from app/views/extranet/alumni/persons/_details.html.erb rename to app/views/extranet/personal_data/_details.html.erb -- GitLab