From ab3ac05aa3eaacfc2823f1bcc0ae0845f57f9fb1 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 3 Mar 2021 15:33:03 +0100 Subject: [PATCH 01/21] Allow inserting hyperlinks in customized info messages --- CHANGELOG.md | 3 +++ app/frontend/templates/admin/settings/general.html | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee6a8d9bc..3ece307cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog Fab-manager +## Next release +- Allow inserting hyperlinks in customized info messages + ## v4.7.3 2021 March 03 - Improved the setup script - Fix a bug: unable to install a new instance with an external reverse proxy diff --git a/app/frontend/templates/admin/settings/general.html b/app/frontend/templates/admin/settings/general.html index d2cbefa19..23c61d3c8 100644 --- a/app/frontend/templates/admin/settings/general.html +++ b/app/frontend/templates/admin/settings/general.html @@ -49,7 +49,7 @@

{{ 'app.admin.settings.message_of_the_machine_booking_page' }}

@@ -58,7 +58,7 @@

{{ 'app.admin.settings.warning_message_of_the_training_booking_page'}}

@@ -67,7 +67,7 @@

{{ 'app.admin.settings.information_message_of_the_training_reservation_page'}}

@@ -76,7 +76,7 @@

{{ 'app.admin.settings.message_of_the_subscriptions_page' }}

@@ -84,7 +84,7 @@

{{ 'app.admin.settings.message_of_the_events_page' }}

@@ -92,7 +92,7 @@

{{ 'app.admin.settings.message_of_the_spaces_page' }}

From a74c5d4c95810236f6329032e51f1cecb614b281 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 3 Mar 2021 17:21:06 +0100 Subject: [PATCH 02/21] WIP: plan description --- app/controllers/api/plans_controller.rb | 2 +- .../src/javascript/components/plan-card.tsx | 9 ++++++++- .../src/stylesheets/app.components.scss | 18 ++++++++++++++++++ app/frontend/templates/admin/plans/_form.html | 11 +++++++++++ config/locales/app.shared.en.yml | 2 ++ config/locales/app.shared.fr.yml | 2 ++ 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/plans_controller.rb b/app/controllers/api/plans_controller.rb index e0d1769de..7e15e5015 100644 --- a/app/controllers/api/plans_controller.rb +++ b/app/controllers/api/plans_controller.rb @@ -68,7 +68,7 @@ class API::PlansController < API::ApiController @parameters = @parameters.require(:plan) .permit(:base_name, :type, :group_id, :amount, :interval, :interval_count, :is_rolling, - :training_credit_nb, :ui_weight, :disabled, :monthly_payment, + :training_credit_nb, :ui_weight, :disabled, :monthly_payment, :description, plan_file_attributes: %i[id attachment _destroy], prices_attributes: %i[id amount]) end diff --git a/app/frontend/src/javascript/components/plan-card.tsx b/app/frontend/src/javascript/components/plan-card.tsx index e6a1beb26..2d9134063 100644 --- a/app/frontend/src/javascript/components/plan-card.tsx +++ b/app/frontend/src/javascript/components/plan-card.tsx @@ -71,6 +71,12 @@ const PlanCard: React.FC = ({ plan, userId, subscribedPlanId, ope const hasAttachment = (): boolean => { return !!plan.plan_file_url; } + /** + * Check if the plan has a description + */ + const hasDescription = (): boolean => { + return !!plan.description; + } /** * Check if the plan is allowing a monthly payment schedule */ @@ -100,6 +106,8 @@ const PlanCard: React.FC = ({ plan, userId, subscribedPlanId, ope
}
+ {hasDescription() &&
} + {hasAttachment() && { t('app.public.plans.more_information') }} {canSubscribeForMe() &&
{!hasSubscribedToThisPlan() &&
} - {hasAttachment() && { t('app.public.plans.more_information') }}
); } diff --git a/app/frontend/src/stylesheets/app.components.scss b/app/frontend/src/stylesheets/app.components.scss index 7c1a082e4..1db1463d1 100644 --- a/app/frontend/src/stylesheets/app.components.scss +++ b/app/frontend/src/stylesheets/app.components.scss @@ -269,6 +269,7 @@ .pricing-panel { border: 1px solid $border-color; + height: 391px; &:first-child { border-right: none; @@ -347,6 +348,11 @@ } } + .plan-description { + max-height: 5.2em; + overflow: hidden; + } + .cta-button { margin: 20px 0; @@ -800,3 +806,15 @@ input[type=date].form-control { margin-left: 1em; } } + +.medium-editor-input { + display: table-cell; + border: 1px solid #c0c0c0; + border-radius: 0.2em; + padding: 0.5em; + width: 100%; + + p { + margin-bottom: 0; + } +} diff --git a/app/frontend/templates/admin/plans/_form.html b/app/frontend/templates/admin/plans/_form.html index b40c91a02..32f25f48b 100644 --- a/app/frontend/templates/admin/plans/_form.html +++ b/app/frontend/templates/admin/plans/_form.html @@ -127,6 +127,17 @@ {{ 'app.shared.plan.monthly_payment_info' }}
+
+ +
+
+
+
+ +
+ diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index e39eec1ed..4ebb8e270 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -192,6 +192,8 @@ en: otherwise_it_will_begin_as_soon_as_it_is_bought: "Otherwise, it will begin as soon as it is bought." monthly_payment: "Monthly payment?" monthly_payment_info: "If monthly payment is enabled, the members will be able to choose between a one-time payment or a payment schedule staged each months." + description: "Description" + type_a_short_description: "Type a short description" information_sheet: "Information sheet" attach_an_information_sheet: "Attach an information sheet" notified_partner: "Notified partner" diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index a320d6d5c..a81baae2e 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -192,6 +192,8 @@ fr: otherwise_it_will_begin_as_soon_as_it_is_bought: "Dans le cas contraire, il prendra effet dès sa date d'achat." monthly_payment: "Paiement mensuel ?" monthly_payment_info: "Si le paiement mensuel est activé, les membres pourront choisir entre un paiement unique ou un échéancier de paiement échelonné chaque mois." + description: "Description" + type_a_short_description: "Saisir une courte description" information_sheet: "Fiche descriptive" attach_an_information_sheet: "Joindre une fiche descriptive" notified_partner: "Partenaire notifié" From 021c019ba45e95752cc8ccb91549f13f89db17d2 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 8 Mar 2021 09:57:11 +0100 Subject: [PATCH 03/21] fix rename service during setup --- setup/setup.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/setup/setup.sh b/setup/setup.sh index e5fd65074..142d2e6ae 100755 --- a/setup/setup.sh +++ b/setup/setup.sh @@ -66,6 +66,7 @@ read_email() config() { + SERVICE="fabmanager" echo 'We recommend nginx to serve the application over the network (internet). You can use your own solution or let this script install and configure nginx for Fab-manager.' read -rp 'Do you want install nginx? (Y/n) ' NGINX Date: Mon, 8 Mar 2021 12:08:17 +0100 Subject: [PATCH 04/21] [bug] script to mount payment-schedules volume results in invalid yml file + improved scripts for mounting volumes + increased verbosity of upgrade script --- CHANGELOG.md | 3 +++ scripts/mount-payment-schedules.sh | 8 +++++--- scripts/mount-webpack.sh | 6 ++++-- setup/upgrade.sh | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ece307cf..d4f3b12f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Next release - Allow inserting hyperlinks in customized info messages +- Improved scripts for mounting volumes +- Increased verbosity of upgrade script +- Fix a bug: mounting the payment-schedules volume in the docker-compose file results in an invalid file ## v4.7.3 2021 March 03 - Improved the setup script diff --git a/scripts/mount-payment-schedules.sh b/scripts/mount-payment-schedules.sh index 7ad7a92e2..2bd354b71 100644 --- a/scripts/mount-payment-schedules.sh +++ b/scripts/mount-payment-schedules.sh @@ -18,9 +18,11 @@ config() add_mount() { - # shellcheck disable=SC2016 - # we don't want to expand ${PWD} - yq -i eval ".services.$SERVICE.volumes += [\"\${PWD}/payment_schedules:/usr/src/app/payment_schedules\"]" docker-compose.yml + if [[ ! $(yq eval ".services.$SERVICE.volumes.[] | select (. == \"*payment_schedules\")" docker-compose.yml) ]]; then + # shellcheck disable=SC2016 + # we don't want to expand ${PWD} + yq -i eval ".services.$SERVICE.volumes += [\"\${PWD}/payment_schedules:/usr/src/app/payment_schedules\"]" docker-compose.yml + fi } proceed() diff --git a/scripts/mount-webpack.sh b/scripts/mount-webpack.sh index 5dc9a2b7e..895891d2d 100644 --- a/scripts/mount-webpack.sh +++ b/scripts/mount-webpack.sh @@ -18,8 +18,10 @@ config() change_mount() { - yq -i eval ".services.$SERVICE.volumes.[] | select(. == \"*assets\") |= \"\${PWD}/public/packs:/usr/src/app/public/packs\"" docker-compose.yml - echo "Service volume was replaced for $SERVICE: /assets changed to /packs" + if [[ $(yq eval ".services.$SERVICE.volumes.[] | select (. == \"*assets\")" docker-compose.yml) ]]; then + yq -i eval ".services.$SERVICE.volumes.[] |= select(. == \"*assets\") |= \"\${PWD}/public/packs:/usr/src/app/public/packs\"" docker-compose.yml + echo "Service volume was replaced for $SERVICE: /assets changed to /packs" + fi } proceed() diff --git a/setup/upgrade.sh b/setup/upgrade.sh index 4075e4969..e6a865e46 100644 --- a/setup/upgrade.sh +++ b/setup/upgrade.sh @@ -87,6 +87,7 @@ add_environments() { for ENV in "${ENVIRONMENTS[@]}"; do if [[ "$ENV" =~ ^[A-Z0-9_]+=.*$ ]]; then + printf "Inserting variable %s...\n" "$ENV" printf "# added on %s\n%s\n" "$(date +%Y-%m-%d\ %R)" "$ENV" >> "config/env" else echo "Ignoring invalid option: -e $ENV. Given value is not valid environment variable, please see https://huit.re/environment-doc" @@ -125,6 +126,7 @@ upgrade() BRANCH='master' if yq eval '.services.*.image | select(. == "sleede/fab-manager*")' docker-compose.yml | grep -q ':dev'; then BRANCH='dev'; fi for SCRIPT in "${SCRIPTS[@]}"; do + printf "Running script %s from branch %s...\n" "$SCRIPT" "$BRANCH" if [[ "$YES_ALL" = "true" ]]; then \curl -sSL "https://raw.githubusercontent.com/sleede/fab-manager/$BRANCH/scripts/$SCRIPT.sh" | bash -s -- -y else @@ -134,6 +136,7 @@ upgrade() compile_assets docker-compose run --rm "$SERVICE" bundle exec rake db:migrate for COMMAND in "${COMMANDS[@]}"; do + printf "Running command %s...\n" "$COMMAND" docker-compose run --rm "$SERVICE" bundle exec "$COMMAND" done docker-compose up -d From 10fbea92892b55e5c0325b4bbc03b3154c603ad6 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 8 Mar 2021 14:09:11 +0100 Subject: [PATCH 05/21] Allow writing short rich descriptions for each subscription plan --- CHANGELOG.md | 4 +- .../src/javascript/components/plan-card.tsx | 42 +++++++------- .../src/javascript/controllers/admin/plans.js | 8 +++ .../src/stylesheets/app.components.scss | 58 ++++++++++++------- app/frontend/src/stylesheets/app.layout.scss | 9 +++ app/frontend/templates/admin/plans/_form.html | 2 +- app/themes/casemate/style.scss.erb | 19 +++--- 7 files changed, 90 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4f3b12f2..7720fbfa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # Changelog Fab-manager ## Next release +- Allow writing short rich descriptions for each subscription plan - Allow inserting hyperlinks in customized info messages - Improved scripts for mounting volumes - Increased verbosity of upgrade script - Fix a bug: mounting the payment-schedules volume in the docker-compose file results in an invalid file +- [TODO DEPLOY] `rails fablab:maintenance:rebuild_stylesheet` ## v4.7.3 2021 March 03 - Improved the setup script @@ -19,7 +21,7 @@ - Fix a bug: unable to upgrade using the easy upgrade command - Fix a security issue: possible SQL injection when dropping the database - Fix a security issue: restrict allowed keys when creating/updating credits -- [TODO DEPLOY] `bundle exec rails fablab:openlab:bulk_export` if you have enabled OpenLab (projects sharing) +- [TODO DEPLOY] `rails fablab:openlab:bulk_export` if you have enabled OpenLab (projects sharing) ## v4.7.1 2021 February 24 - Fix a security issue: updated axios to 0.21.1 to fix [CVE-2020-28168](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-28168) diff --git a/app/frontend/src/javascript/components/plan-card.tsx b/app/frontend/src/javascript/components/plan-card.tsx index 2d9134063..2911e8e12 100644 --- a/app/frontend/src/javascript/components/plan-card.tsx +++ b/app/frontend/src/javascript/components/plan-card.tsx @@ -106,26 +106,28 @@ const PlanCard: React.FC = ({ plan, userId, subscribedPlanId, ope
} - {hasDescription() &&
} - {hasAttachment() && { t('app.public.plans.more_information') }} - {canSubscribeForMe() &&
- {!hasSubscribedToThisPlan() && } - {hasSubscribedToThisPlan() && } -
} - {canSubscribeForOther() &&
- -
} +
+ {hasDescription() &&
} + {hasAttachment() && { t('app.public.plans.more_information') }} + {canSubscribeForMe() &&
+ {!hasSubscribedToThisPlan() && } + {hasSubscribedToThisPlan() && } +
} + {canSubscribeForOther() &&
+ +
} +
); } diff --git a/app/frontend/src/javascript/controllers/admin/plans.js b/app/frontend/src/javascript/controllers/admin/plans.js index 9172956ab..bc230b43d 100644 --- a/app/frontend/src/javascript/controllers/admin/plans.js +++ b/app/frontend/src/javascript/controllers/admin/plans.js @@ -64,6 +64,14 @@ class PlanController { return file._destroy = true; } }; + + /** + * Check and limit + * @param content + */ + $scope.limitDescriptionSize = function (content) { + alert(content); + }; } } diff --git a/app/frontend/src/stylesheets/app.components.scss b/app/frontend/src/stylesheets/app.components.scss index 1db1463d1..3d52a94c2 100644 --- a/app/frontend/src/stylesheets/app.components.scss +++ b/app/frontend/src/stylesheets/app.components.scss @@ -281,6 +281,13 @@ @include border-radius(0 3px 3px 0); } + .plan-card { + height: 100%; + display: flex; + flex-direction: column; + justify-content: flex-start; + } + .title { margin: 10px 0; font-size: rem-calc(16); @@ -348,31 +355,38 @@ } } - .plan-description { - max-height: 5.2em; - overflow: hidden; - } + .card-footer { + display: flex; + flex-direction: column; + justify-content: space-around; + height: 100%; - .cta-button { - margin: 20px 0; - - .subscribe-button { - @extend .btn; - @extend .rounded; - - outline: 0; - font-weight: 600; - font-size: rem-calc(16); - background-color: white; - padding-left: 30px; - padding-right: 30px; + .plan-description { + max-height: 5.2em; + overflow: hidden; } - button.subscribe-button:focus, button.subscribe-button:hover { - outline: 0; + + .cta-button { + margin: 20px 0; + + .subscribe-button { + @extend .btn; + @extend .rounded; + + outline: 0; + font-weight: 600; + font-size: rem-calc(16); + background-color: white; + padding-left: 30px; + padding-right: 30px; + } + button.subscribe-button:focus, button.subscribe-button:hover { + outline: 0; + } + } + .info-link { + margin-top: 1em; } - } - .info-link { - margin-top: 1em; } } diff --git a/app/frontend/src/stylesheets/app.layout.scss b/app/frontend/src/stylesheets/app.layout.scss index fe62d9d64..fb5d2bd17 100644 --- a/app/frontend/src/stylesheets/app.layout.scss +++ b/app/frontend/src/stylesheets/app.layout.scss @@ -686,3 +686,12 @@ body.container { text-align: center; vertical-align: middle; } + +.plan-description-input .medium-editor-input div[medium-editor] { + max-height: 5.2em; + overflow: hidden; + + & p:nth-child(2n+3), p:nth-child(2n+4) { + display: none; + } +} diff --git a/app/frontend/templates/admin/plans/_form.html b/app/frontend/templates/admin/plans/_form.html index 32f25f48b..7161b264e 100644 --- a/app/frontend/templates/admin/plans/_form.html +++ b/app/frontend/templates/admin/plans/_form.html @@ -127,7 +127,7 @@ {{ 'app.shared.plan.monthly_payment_info' }}
-
+
Date: Mon, 8 Mar 2021 14:21:58 +0100 Subject: [PATCH 07/21] Do not close login modal when clicking on the backdrop --- CHANGELOG.md | 1 + app/frontend/src/javascript/controllers/application.js.erb | 1 + app/frontend/src/stylesheets/app.layout.scss | 6 ++++++ app/frontend/templates/shared/deviseModal.html | 1 + 4 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a901f4e8..5536f8fb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Allow writing short rich descriptions for each subscription plan - Allow inserting hyperlinks in customized info messages - Use the primary color to display plans' price in the public view +- Do not close login modal when clicking on the backdrop - Improved scripts for mounting volumes - Increased verbosity of upgrade script - Fix a bug: mounting the payment-schedules volume in the docker-compose file results in an invalid file diff --git a/app/frontend/src/javascript/controllers/application.js.erb b/app/frontend/src/javascript/controllers/application.js.erb index 9e9a58de0..c25601eb5 100644 --- a/app/frontend/src/javascript/controllers/application.js.erb +++ b/app/frontend/src/javascript/controllers/application.js.erb @@ -408,6 +408,7 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco <% else %> return $uibModal.open({ templateUrl: '/shared/deviseModal.html', + backdrop: 'static', size: 'sm', resolve: { settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['confirmation_required']" }).$promise; }] diff --git a/app/frontend/src/stylesheets/app.layout.scss b/app/frontend/src/stylesheets/app.layout.scss index fb5d2bd17..549bda911 100644 --- a/app/frontend/src/stylesheets/app.layout.scss +++ b/app/frontend/src/stylesheets/app.layout.scss @@ -695,3 +695,9 @@ body.container { display: none; } } + +.close-modal-button { + position: absolute; + right: 13px; + cursor: pointer; +} diff --git a/app/frontend/templates/shared/deviseModal.html b/app/frontend/templates/shared/deviseModal.html index ef8b95187..11e946442 100644 --- a/app/frontend/templates/shared/deviseModal.html +++ b/app/frontend/templates/shared/deviseModal.html @@ -1,6 +1,7 @@