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',
'type': 'textarea',
'value': ''
},
'shop_opening_hours' : {
'title': 'Horaires ouverture magasin',
'type': 'textarea',
'value': ''
}
}
def config(request):
......
......@@ -24,6 +24,14 @@ body {
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 {
flex: 1 0 90%;
min-height: 100px;
......
......@@ -4,6 +4,7 @@ from outils.for_view_imports import *
from django.urls import reverse
from outils.common import Verification
from outils.common import MConfig
from members.models import CagetteMember
from shifts.models import CagetteShift
from members_space.models import CagetteMembersSpace
......@@ -103,6 +104,7 @@ def index(request, exception=None):
if hasattr(settings, 'SHIFT_EXCHANGE_DAYS_TO_HIDE'):
days_to_hide = settings.SHIFT_EXCHANGE_DAYS_TO_HIDE
context['daysToHide'] = days_to_hide
else:
# may arrive when switching database without cleaning cookie
return redirect('/website/deconnect')
......@@ -114,6 +116,12 @@ def home(request):
context = {
'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))
def my_info(request):
......
......@@ -3,20 +3,34 @@ var param_template = $('#templates #param'),
main_content = $('#main_content');
function save_module_settings() {
var form_data = new FormData(main_content.get(0));
var data = {};
var form_elts = $('.input-container'),
data = {};
for (var pair of form_data.entries()) {
let val = pair[1],
key = pair[0];
let elt = main_content.find('[name="' + key +'"]');
data[key] = {title: elt.closest('.param').find('label')
.text(),
type: elt.get(0).type,
value: val};
}
form_elts.each(function(i, elt){
const label = $(elt).closest('.param').find('label'),
key = label.attr('for'),
title = label.text();
if (key.length > 0 && key != 'iname') {
let value = "",
type = "";
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(
'settings', {params: JSON.stringify(data)},
function(err, result) {
......@@ -39,17 +53,35 @@ 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() {
$.ajax('settings')
.done(function(rData) {
try {
if (typeof rData.res.settings != "undefined") {
var added_elts = [];
var added_elts = [],
quill_containers = [];
for (let key in rData.res.settings) {
var param = $(param_template.clone().html());
var input = null;
let data = rData.res.settings[key];
param.find('label').text(data.title)
.attr('for', key);
......@@ -57,6 +89,16 @@ function get_module_settings() {
param.find('input').remove();
input = param.find('textarea');
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 {
param.find('textarea').remove();
input = param.find('input');
......@@ -69,12 +111,20 @@ function get_module_settings() {
console.log(param)
*/
param.appendTo(main_content);
added_elts.push(key);
}
if (added_elts.length > 0) {
submit_btn.appendTo(main_content);
}
submit_btn.click(save_module_settings);
quill_containers.forEach(function(params){
quillify(params);
});
// setTimeout(function() {
// }, 5000);
}
} catch (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 @@
À venir...
</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>
\ No newline at end of file
......@@ -3,6 +3,11 @@
{% block additionnal_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 %}
......@@ -20,8 +25,10 @@
<div id="param">
<div class="param">
<label for="iname"></label>
<input type="text" name="iname" value="" />
<textarea name="iname" value="" cols="255" rows="10"></textarea>
<div class="input-container">
<input type="text" name="iname" value="" />
<textarea name="iname" value="" cols="255" rows="10"></textarea>
</div>
</div>
</div>
<div id="submit_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