Commit 24013b6b by Damien Moulard

Merge branch 'evolution_bdm' of…

Merge branch 'evolution_bdm' of gl.cooperatic.fr:cooperatic-foodcoops/third-party into evolution_bdm
parents 8d67c83d d3bee25b
Pipeline #1329 failed with stage
in 1 minute 25 seconds
...@@ -15,6 +15,11 @@ default_msettings = {'msg_accueil': {'title': 'Message borne accueil', ...@@ -15,6 +15,11 @@ default_msettings = {'msg_accueil': {'title': 'Message borne accueil',
'type': 'textarea', 'type': 'textarea',
'value': '' 'value': ''
}, },
'shop_opening_hours' : {
'title': 'Horaires ouverture magasin',
'type': 'textarea',
'value': ''
}
} }
def config(request): def config(request):
......
...@@ -24,6 +24,14 @@ body { ...@@ -24,6 +24,14 @@ body {
box-shadow: 2px 2px 3px rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.1); box-shadow: 2px 2px 3px rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.1);
} }
.subtile {
}
.subtile.two {
max-width: 45%;
}
.full_width_tile { .full_width_tile {
flex: 1 0 90%; flex: 1 0 90%;
min-height: 100px; min-height: 100px;
......
...@@ -4,6 +4,7 @@ from outils.for_view_imports import * ...@@ -4,6 +4,7 @@ from outils.for_view_imports import *
from django.urls import reverse from django.urls import reverse
from outils.common import Verification from outils.common import Verification
from outils.common import MConfig
from members.models import CagetteMember from members.models import CagetteMember
from shifts.models import CagetteShift from shifts.models import CagetteShift
from members_space.models import CagetteMembersSpace from members_space.models import CagetteMembersSpace
...@@ -103,6 +104,7 @@ def index(request, exception=None): ...@@ -103,6 +104,7 @@ def index(request, exception=None):
if hasattr(settings, 'SHIFT_EXCHANGE_DAYS_TO_HIDE'): if hasattr(settings, 'SHIFT_EXCHANGE_DAYS_TO_HIDE'):
days_to_hide = settings.SHIFT_EXCHANGE_DAYS_TO_HIDE days_to_hide = settings.SHIFT_EXCHANGE_DAYS_TO_HIDE
context['daysToHide'] = days_to_hide context['daysToHide'] = days_to_hide
else: else:
# may arrive when switching database without cleaning cookie # may arrive when switching database without cleaning cookie
return redirect('/website/deconnect') return redirect('/website/deconnect')
...@@ -114,6 +116,12 @@ def home(request): ...@@ -114,6 +116,12 @@ def home(request):
context = { context = {
'title': 'Espace Membres', 'title': 'Espace Membres',
} }
# Get messages to display
msettings = MConfig.get_settings('members')
if 'msg_accueil' in msettings:
context['msg_accueil'] = msettings['msg_accueil']['value']
if 'shop_opening_hours' in msettings:
context['shop_opening_hours'] = msettings['shop_opening_hours']['value']
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def my_info(request): def my_info(request):
......
...@@ -3,20 +3,34 @@ var param_template = $('#templates #param'), ...@@ -3,20 +3,34 @@ var param_template = $('#templates #param'),
main_content = $('#main_content'); main_content = $('#main_content');
function save_module_settings() { function save_module_settings() {
var form_data = new FormData(main_content.get(0)); var form_elts = $('.input-container'),
var data = {}; data = {};
for (var pair of form_data.entries()) { form_elts.each(function(i, elt){
let val = pair[1], const label = $(elt).closest('.param').find('label'),
key = pair[0]; key = label.attr('for'),
let elt = main_content.find('[name="' + key +'"]'); title = label.text();
if (key.length > 0 && key != 'iname') {
data[key] = {title: elt.closest('.param').find('label') let value = "",
.text(), type = "";
type: elt.get(0).type,
value: val};
if ($(elt).hasClass('ql-container')) {
type = 'textarea';
value = $(elt).find('.ql-editor').html().replace('<p><br></p>','')
} else {
type = 'input';
value = $(elt).find('input').val();
}
data[key] = {
title: title,
type: type,
value: value
};
} }
});
post_form( post_form(
'settings', {params: JSON.stringify(data)}, 'settings', {params: JSON.stringify(data)},
function(err, result) { function(err, result) {
...@@ -39,24 +53,52 @@ function save_module_settings() { ...@@ -39,24 +53,52 @@ function save_module_settings() {
); );
} }
function quillify(params) {
let quill = new Quill(params.id, {
modules: {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'color': [] }, { 'background': [] }],
]
},
placeholder: '',
theme: 'snow'
});
quill.root.innerHTML = params.content;
}
function get_module_settings() { function get_module_settings() {
$.ajax('settings') $.ajax('settings')
.done(function(rData) { .done(function(rData) {
try { try {
if (typeof rData.res.settings != "undefined") { if (typeof rData.res.settings != "undefined") {
var added_elts = []; var added_elts = [],
quill_containers = [];
for (let key in rData.res.settings) { for (let key in rData.res.settings) {
var param = $(param_template.clone().html()); var param = $(param_template.clone().html());
var input = null; var input = null;
let data = rData.res.settings[key]; let data = rData.res.settings[key];
param.find('label').text(data.title) param.find('label').text(data.title)
.attr('for', key); .attr('for', key);
if (data.type == 'textarea') { if (data.type == 'textarea') {
param.find('input').remove(); param.find('input').remove();
input = param.find('textarea'); input = param.find('textarea');
input.attr('name', key).text(data.value); input.attr('name', key).text(data.value);
input.closest('div').attr('id', 'quill-' + key)
.css('height', '375px')
quill_containers.push(
{
id: '#quill-' + key,
content: data.value
}
)
} else { } else {
param.find('textarea').remove(); param.find('textarea').remove();
input = param.find('input'); input = param.find('input');
...@@ -69,12 +111,20 @@ function get_module_settings() { ...@@ -69,12 +111,20 @@ function get_module_settings() {
console.log(param) console.log(param)
*/ */
param.appendTo(main_content); param.appendTo(main_content);
added_elts.push(key); added_elts.push(key);
} }
if (added_elts.length > 0) { if (added_elts.length > 0) {
submit_btn.appendTo(main_content); submit_btn.appendTo(main_content);
} }
submit_btn.click(save_module_settings); submit_btn.click(save_module_settings);
quill_containers.forEach(function(params){
quillify(params);
});
// setTimeout(function() {
// }, 5000);
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -73,5 +73,17 @@ ...@@ -73,5 +73,17 @@
À venir... À venir...
</div> </div>
</div> </div>
<div class="tile" id="home_tile_message">
<div class="tile_title">
<i class="fas fa-newspaper tile_icon"></i>
Informations magasins
</div>
<div class="subtile">
{{msg_accueil|safe}}
</div>
<div class="subtile">
{{shop_opening_hours|safe}}
</div>
</div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
{% block additionnal_css %} {% block additionnal_css %}
<link rel="stylesheet" href="{% static 'css/module_config.css' %}"> <link rel="stylesheet" href="{% static 'css/module_config.css' %}">
<link rel="stylesheet" href="{% static 'quill/quill.snow.css' %}">
{% endblock %}
{% block additionnal_scripts %}
<script type="text/javascript" src="{% static 'quill/quill.min.js' %}"></script>
{% endblock %} {% endblock %}
...@@ -20,10 +25,12 @@ ...@@ -20,10 +25,12 @@
<div id="param"> <div id="param">
<div class="param"> <div class="param">
<label for="iname"></label> <label for="iname"></label>
<div class="input-container">
<input type="text" name="iname" value="" /> <input type="text" name="iname" value="" />
<textarea name="iname" value="" cols="255" rows="10"></textarea> <textarea name="iname" value="" cols="255" rows="10"></textarea>
</div> </div>
</div> </div>
</div>
<div id="submit_button"> <div id="submit_button">
<div> <div>
<button type="button" class="btn--primary">Enregistrer</button> <button type="button" class="btn--primary">Enregistrer</button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment