mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
[ongoing] save as draft or publish
This commit is contained in:
parent
8fae8b104d
commit
7a2fc7c42e
@ -12,8 +12,8 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
Application.Controllers.controller('SettingsController', ['$scope', 'Setting', 'growl', 'settingsPromise', 'cgvFile', 'cguFile', 'logoFile', 'logoBlackFile', 'faviconFile', 'profileImageFile', 'CSRF', '_t',
|
||||
function ($scope, Setting, growl, settingsPromise, cgvFile, cguFile, logoFile, logoBlackFile, faviconFile, profileImageFile, CSRF, _t) {
|
||||
Application.Controllers.controller('SettingsController', ['$scope', '$uibModal', 'Setting', 'growl', 'settingsPromise', 'privacyDraftsPromise', 'cgvFile', 'cguFile', 'logoFile', 'logoBlackFile', 'faviconFile', 'profileImageFile', 'CSRF', '_t',
|
||||
function ($scope, $uibModal, Setting, growl, settingsPromise, privacyDraftsPromise, cgvFile, cguFile, logoFile, logoBlackFile, faviconFile, profileImageFile, CSRF, _t) {
|
||||
/* PUBLIC SCOPE */
|
||||
|
||||
// timepickers steps configuration
|
||||
@ -48,12 +48,16 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
|
||||
cgv: false
|
||||
};
|
||||
|
||||
// various parametrable settings
|
||||
// full history of privacy policy drafts
|
||||
$scope.privacyDraftsHistory = [];
|
||||
|
||||
// various configurable settings
|
||||
$scope.twitterSetting = { name: 'twitter_name', value: settingsPromise.twitter_name };
|
||||
$scope.aboutTitleSetting = { name: 'about_title', value: settingsPromise.about_title };
|
||||
$scope.aboutBodySetting = { name: 'about_body', value: settingsPromise.about_body };
|
||||
$scope.privacyBodySetting = { name: 'privacy_body', value: settingsPromise.privacy_body };
|
||||
$scope.privacyDpoSetting = { name: 'privacy_dpo', value: settingsPromise.privacy_dpo };
|
||||
$scope.privacyDraftSetting = { name: 'privacy_draft', value: privacyDraftsPromise.setting.value };
|
||||
$scope.aboutContactsSetting = { name: 'about_contacts', value: settingsPromise.about_contacts };
|
||||
$scope.homeBlogpostSetting = { name: 'home_blogpost', value: settingsPromise.home_blogpost };
|
||||
$scope.machineExplicationsAlert = { name: 'machine_explications_alert', value: settingsPromise.machine_explications_alert };
|
||||
@ -121,6 +125,9 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
|
||||
value: (settingsPromise.display_name_enable === 'true')
|
||||
};
|
||||
|
||||
// binding to the privacy policy revision select
|
||||
$scope.policyVersion = null;
|
||||
|
||||
/**
|
||||
* For use with 'ng-class', returns the CSS class name for the uploads previews.
|
||||
* The preview may show a placeholder or the content of the file depending on the upload state.
|
||||
@ -159,6 +166,23 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
|
||||
, error => console.log(error));
|
||||
};
|
||||
|
||||
$scope.savePrivacyPolicy = function () {
|
||||
// open modal
|
||||
const modalInstance = $uibModal.open({
|
||||
templateUrl: '<%= asset_path "admin/settings/save_policy.html" %>',
|
||||
controller: 'SavePolicyController'
|
||||
});
|
||||
|
||||
// once done, update the invoice model and inform the admin
|
||||
return modalInstance.result.then(function (res) {
|
||||
$scope.invoices.unshift(res.avoir);
|
||||
return Invoice.get({ id: invoice.id }, function (data) {
|
||||
invoice.has_avoir = data.has_avoir;
|
||||
return growl.success(_t('invoices.refund_invoice_successfully_created'));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* For use with ngUpload (https://github.com/twilson63/ngUpload).
|
||||
* Intended to be the callback when the upload is done: Any raised error will be displayed in a growl
|
||||
@ -208,6 +232,13 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
|
||||
*/
|
||||
$scope.addLoader = target => $scope.loader[target] = true;
|
||||
|
||||
/**
|
||||
* Change the revision of the displayed privacy policy, from drafts history
|
||||
*/
|
||||
$scope.handlePolicyRevisionChange = function () {
|
||||
$scope.privacyDraftSetting.value = $scope.privacyDraftsHistory[$scope.policyVersion].content;
|
||||
};
|
||||
|
||||
/* PRIVATE SCOPE */
|
||||
|
||||
/**
|
||||
@ -249,6 +280,10 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
|
||||
$scope.methods.profileImage = 'put';
|
||||
return $scope.actionUrl.profileImage += '/profile-image-file';
|
||||
}
|
||||
|
||||
privacyDraftsPromise.setting.history.forEach(function (draft) {
|
||||
$scope.privacyDraftsHistory.push({ id: draft.id, name: _t('settings.privacy.draft_from_USER_DATE', { USER: draft.user, DATE: draft.created_at }), content: draft.value });
|
||||
});
|
||||
};
|
||||
|
||||
// init the controller (call at the end !)
|
||||
@ -256,3 +291,22 @@ Application.Controllers.controller('SettingsController', ['$scope', 'Setting', '
|
||||
}
|
||||
|
||||
]);
|
||||
|
||||
|
||||
/**
|
||||
* Controller used in the invoice refunding modal window
|
||||
*/
|
||||
Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModalInstance', 'growl', '_t',
|
||||
function ($scope, $uibModalInstance, growl, _t) {
|
||||
/* PUBLIC SCOPE */
|
||||
$scope.save = function () {
|
||||
|
||||
};
|
||||
$scope.publish = function () {
|
||||
|
||||
};
|
||||
$scope.cancel = function () {
|
||||
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
@ -1074,6 +1074,7 @@ angular.module('application.router', ['ui.router'])
|
||||
'display_name_enable', \
|
||||
'machines_sort_by']` }).$promise;
|
||||
}],
|
||||
privacyDraftsPromise: ['Setting', function (Setting) { return Setting.get({ name: 'privacy_draft', history: true }).$promise; }],
|
||||
cguFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'cgu-file' }).$promise; }],
|
||||
cgvFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'cgv-file' }).$promise; }],
|
||||
faviconFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'favicon-file' }).$promise; }],
|
||||
|
@ -3,13 +3,16 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-1">
|
||||
<select class="form-control m-b" ng-options="d.id as d.name for d in privacyDraftsHistory" ng-model="policyVersion" ng-change="handlePolicyRevisionChange()">
|
||||
<option value="" translate>{{ 'settings.privacy.current_policy' }}</option>
|
||||
</select>
|
||||
<div class="text-justify" ng-model="privacyBodySetting.value" medium-editor options='{"placeholder": "{{ "settings.input_the_main_content" | translate }}",
|
||||
"buttons": ["bold", "italic", "anchor", "header1", "header2" ]
|
||||
}'>
|
||||
|
||||
</div>
|
||||
<span class="help-block text-info text-xs"><i class="fa fa-lightbulb-o"></i> {{ 'settings.drag_and_drop_to_insert_images' | translate }}</span>
|
||||
<button name="button" class="btn btn-warning" ng-click="save(privacyBodySetting)" translate>{{ 'save' }}</button>
|
||||
<button name="button" class="btn btn-warning" ng-click="savePrivacyPolicy()" translate>{{ 'save' }}</button>
|
||||
</div>
|
||||
<div class="col-md-4 col-md-offset-2">
|
||||
<div ng-model="privacyDpoSetting.value" medium-editor options='{"placeholder": "{{ "settings.privacy.input_the_dpo" | translate }}",
|
||||
|
12
app/assets/templates/admin/settings/save_policy.html
Normal file
12
app/assets/templates/admin/settings/save_policy.html
Normal file
@ -0,0 +1,12 @@
|
||||
<div class="modal-header">
|
||||
<h3 class="text-center red" translate>{{ 'settings.privacy.save_or_publish' }}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p translate>{{ 'settings.privacy.save_or_publish_body' }}</p>
|
||||
<p translate>{{ 'settings.privacy.publish_will_notify' }}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-info" ng-click="save()" translate>{{ 'save' }}</button>
|
||||
<button class="btn btn-warning" ng-click="publish()" translate>{{ 'settings.privacy.publish' }}</button>
|
||||
<button class="btn btn-default" ng-click="cancel()" translate>{{ 'cancel' }}</button>
|
||||
</div>
|
@ -4,6 +4,7 @@ class Setting < ActiveRecord::Base
|
||||
{ in: %w[about_title
|
||||
about_body
|
||||
about_contacts
|
||||
privacy_draft
|
||||
privacy_body
|
||||
privacy_dpo
|
||||
twitter_name
|
||||
|
@ -2,7 +2,7 @@ json.setting do
|
||||
json.partial! 'api/settings/setting', setting: @setting
|
||||
if @show_history
|
||||
json.history @setting.history_values do |value|
|
||||
json.extract! value, :value, :created_at
|
||||
json.extract! value, :id, :value, :created_at
|
||||
unless value.user_id.nil?
|
||||
json.user do
|
||||
json.id value.user_id
|
||||
|
@ -688,6 +688,8 @@ en:
|
||||
about_title: "\"About\" page title"
|
||||
about_body: "\"About\" page content"
|
||||
about_contacts: "\"About\" page contacts"
|
||||
privacy_body: "privacy policy"
|
||||
privacy_dpo: "data protection officer address"
|
||||
booking_window_start: "opening time"
|
||||
booking_window_end: "closing time"
|
||||
booking_move_enable: "reservation moving enabling"
|
||||
@ -714,6 +716,13 @@ en:
|
||||
updated_at: "Last update date"
|
||||
privacy:
|
||||
title: "Privacy policy"
|
||||
input_the_dpo: "Input the contact of the Data Protection Officer"
|
||||
current_policy: "Current policy"
|
||||
draft_from_USER_DATE: "Draft, saved by {{USER}}, on {{DATE}}"
|
||||
save_or_publish: "Save or publish?"
|
||||
save_or_publish_body: "Do you want to publish a new version of the privacy policy or save it as a draft?"
|
||||
publish_will_notify: "Publish a new version will send a notification to every users."
|
||||
publish: "Publish"
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Create new API client"
|
||||
|
@ -688,6 +688,8 @@ es:
|
||||
about_title: "Título de la página \"Acerca de\""
|
||||
about_body: "Contenido de la página \"Acerca de\""
|
||||
about_contacts: "Página contactos\"Acerca de\""
|
||||
privacy_body: "privacy policy" # translation_missing
|
||||
privacy_dpo: "data protection officer address" # translation_missing
|
||||
booking_window_start: "hora de apertura"
|
||||
booking_window_end: "hora de cierre"
|
||||
booking_move_enable: "Activar cambio de reserva"
|
||||
@ -714,6 +716,13 @@ es:
|
||||
updated_at: "Fecha de actualización"
|
||||
privacy:
|
||||
title: "Política de privacidad"
|
||||
input_the_dpo: "Input the contact of the Data Protection Officer" # translation_missing
|
||||
current_policy: "Current policy" # translation_missing
|
||||
draft_from_USER_DATE: "Draft, saved by {{USER}}, on {{DATE}}" # translation_missing
|
||||
save_or_publish: "Save or publish?" # translation_missing
|
||||
save_or_publish_body: "Do you want to publish a new version of the privacy policy or save it as a draft?" # translation_missing
|
||||
publish_will_notify: "Publish a new version will send a notification to every users." # translation_missing
|
||||
publish: "Publish" # translation_missing
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Crear un nuevo cliente de API"
|
||||
|
@ -688,6 +688,8 @@ fr:
|
||||
about_title: "titre de la page \"À propos\""
|
||||
about_body: "corps de la page \"À propos\""
|
||||
about_contacts: "contacts sur la page \"À propos\""
|
||||
privacy_body: "la politique de confidentialité"
|
||||
privacy_dpo: "l'adresse du délégué à la protection des données"
|
||||
booking_window_start: "l'heure d'ouverture"
|
||||
booking_window_end: "l'heure de fermeture"
|
||||
booking_move_enable: "l'activation du déplacement de réservation"
|
||||
@ -715,6 +717,12 @@ fr:
|
||||
privacy:
|
||||
title: "Politique de confidentialité"
|
||||
input_the_dpo: "Saisir le contact du Délégué à la protection des données"
|
||||
current_policy: "Politique courante"
|
||||
draft_from_USER_DATE: "Brouillon, enregistré par {{USER}}, le {{DATE}}"
|
||||
save_or_publish: "Enregistrer ou publier ?"
|
||||
save_or_publish_body: "Voulez-vous publier une nouvelle version de la politique de confidentialité ou bien l'enregistrer comme brouillon ?"
|
||||
publish_will_notify: "Publier une nouvelle version enverra une notification à l'ensemble des utilisateurs."
|
||||
publish: "Publier"
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Créer un compte client"
|
||||
|
@ -688,6 +688,8 @@ pt:
|
||||
about_title: "\"Sobre\" título da página"
|
||||
about_body: "\"Sobre\" conteúdo da página"
|
||||
about_contacts: "\"Sobre\" página de contatos"
|
||||
privacy_body: "privacy policy" # translation_missing
|
||||
privacy_dpo: "data protection officer address" # translation_missing
|
||||
booking_window_start: "Horário de abertura"
|
||||
booking_window_end: "Horário de fechamento"
|
||||
booking_move_enable: "Mover reserva habilitado"
|
||||
@ -714,6 +716,13 @@ pt:
|
||||
updated_at: "TODO"
|
||||
privacy:
|
||||
title: "Política de privacidade"
|
||||
input_the_dpo: "Input the contact of the Data Protection Officer" # translation_missing
|
||||
current_policy: "Current policy" # translation_missing
|
||||
draft_from_USER_DATE: "Draft, saved by {{USER}}, on {{DATE}}" # translation_missing
|
||||
save_or_publish: "Save or publish?" # translation_missing
|
||||
save_or_publish_body: "Do you want to publish a new version of the privacy policy or save it as a draft?" # translation_missing
|
||||
publish_will_notify: "Publish a new version will send a notification to every users." # translation_missing
|
||||
publish: "Publish" # translation_missing
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Criar novo cliente de API"
|
||||
|
Loading…
x
Reference in New Issue
Block a user