Merge remote-tracking branch 'origin/upgrade-sf3' into upgrade-sf3

This commit is contained in:
Julien Fastré 2018-04-27 13:37:34 +02:00
commit 8d9d737dd8
3 changed files with 71 additions and 65 deletions

View File

@ -93,7 +93,7 @@ var chill = function() {
* *
* @param{string} form_id An identification string of the form * @param{string} form_id An identification string of the form
* @param{string} alert_message The alert message to display * @param{string} alert_message The alert message to display
* @param{boolean} check_unsaved_data If true display the alert message only when the form * @param{boolean} check_unsaved_data If true display the alert message only when the form
* contains some modified fields otherwise always display the alert when leaving * contains some modified fields otherwise always display the alert when leaving
* @return nothing * @return nothing
*/ */
@ -123,12 +123,12 @@ var chill = function() {
}); });
} }
/** /**
* Mark the choices "not specified" as check by default. * Mark the choices "not specified" as check by default.
* *
* This function apply to `custom field choices` when the `required` * This function apply to `custom field choices` when the `required`
* option is false and `expanded` is true (checkboxes or radio buttons). * option is false and `expanded` is true (checkboxes or radio buttons).
* *
* @param{string} choice_name the name of the input * @param{string} choice_name the name of the input
*/ */
function checkNullValuesInChoices(choice_name) { function checkNullValuesInChoices(choice_name) {
@ -184,21 +184,21 @@ var chill = function() {
* child) of a given form : each parent option has a category, the * child) of a given form : each parent option has a category, the
* child select only display options that have the same category of the * child select only display options that have the same category of the
* parent optionn * parent optionn
* *
* The parent must have the class "chill-category-link-parent". * The parent must have the class "chill-category-link-parent".
* *
* The children must have the class "chill-category-link-child". Each option * The children must have the class "chill-category-link-child". Each option
* of the parent must have the attribute `data-link-category`, with the value of * of the parent must have the attribute `data-link-category`, with the value of
* the connected option in parent. * the connected option in parent.
* *
* Example : * Example :
* *
* ```html * ```html
* <select name="country" class="chill-category-link-parent"> * <select name="country" class="chill-category-link-parent">
* <option value="BE">Belgium</option> * <option value="BE">Belgium</option>
* <option value="FR">France</option> * <option value="FR">France</option>
* </select> * </select>
* *
* <select name="cities">class="chill-category-link-children"> * <select name="cities">class="chill-category-link-children">
* <option value="paris" data-link-category="FR">Paris</option> * <option value="paris" data-link-category="FR">Paris</option>
* <option value="toulouse" data-link-category="FR">Toulouse</option> * <option value="toulouse" data-link-category="FR">Toulouse</option>
@ -207,7 +207,7 @@ var chill = function() {
* <option value="mons" data-link-category="BE">Mons</option> * <option value="mons" data-link-category="BE">Mons</option>
* </select> * </select>
* ``` * ```
* *
* TODO ECRIRE LA DOC METTRE LES TESTS DANS git : * TODO ECRIRE LA DOC METTRE LES TESTS DANS git :
* tester que init est ok : * tester que init est ok :
- quand vide - quand vide
@ -224,7 +224,7 @@ var chill = function() {
form.old_category = null; form.old_category = null;
form.link_parent = $(form).find('.chill-category-link-parent'); form.link_parent = $(form).find('.chill-category-link-parent');
form.link_child = $(form).find('.chill-category-link-child'); form.link_child = $(form).find('.chill-category-link-child');
// check if the parent allow multiple or single results // check if the parent allow multiple or single results
parent_multiple = $(form).find('.chill-category-link-parent').get(0).multiple; parent_multiple = $(form).find('.chill-category-link-parent').get(0).multiple;
// if we use select2, parent_multiple will be `undefined` // if we use select2, parent_multiple will be `undefined`
@ -233,10 +233,10 @@ var chill = function() {
// we suppose that multiple is false (old behaviour) // we suppose that multiple is false (old behaviour)
parent_multiple = false parent_multiple = false
} }
$(form.link_parent).addClass('select2'); $(form.link_parent).addClass('select2');
$(form.link_parant).select2({allowClear: true}); // it is weird: when I fix the typo here, the whole stuff does not work anymore... $(form.link_parant).select2({allowClear: true}); // it is weird: when I fix the typo here, the whole stuff does not work anymore...
if (parent_multiple == false) { if (parent_multiple == false) {
form.old_category = null; form.old_category = null;
@ -279,9 +279,9 @@ var chill = function() {
} }
}); });
} else { } else {
var i=0, var i=0,
selected_items = $(form.link_parent).find(':selected'); selected_items = $(form.link_parent).find(':selected');
form.old_categories = []; form.old_categories = [];
for (i=0;i < selected_items.length; i++) { for (i=0;i < selected_items.length; i++) {
form.old_categories.push(selected_items[i].value); form.old_categories.push(selected_items[i].value);
@ -314,13 +314,13 @@ var chill = function() {
}); });
form.link_parent.change(function() { form.link_parent.change(function() {
var new_categories = [], var new_categories = [],
selected_items = $(form.link_parent).find(':selected'), selected_items = $(form.link_parent).find(':selected'),
visible; visible;
for (i=0;i < selected_items.length; i++) { for (i=0;i < selected_items.length; i++) {
new_categories.push(selected_items[i].value); new_categories.push(selected_items[i].value);
} }
if(new_categories != form.old_categories) { if(new_categories != form.old_categories) {
$(form.link_child).find('option') $(form.link_child).find('option')
.each(function(i,e) { .each(function(i,e) {
@ -352,16 +352,16 @@ var chill = function() {
form.old_categories = new_categories; form.old_categories = new_categories;
} }
}); });
} }
}); });
} }
function _displayHideTargetWithCheckbox(checkbox) { function _displayHideTargetWithCheckbox(checkbox) {
var target = checkbox.dataset.displayTarget, var target = checkbox.dataset.displayTarget,
hideableElements; hideableElements;
hideableElements = document.querySelectorAll('[data-display-show-hide="' + target + '"]'); hideableElements = document.querySelectorAll('[data-display-show-hide="' + target + '"]');
if (checkbox.checked) { if (checkbox.checked) {
for (let i=0; i < hideableElements.length; i = i+1) { for (let i=0; i < hideableElements.length; i = i+1) {
hideableElements[i].style.display = "unset"; hideableElements[i].style.display = "unset";
@ -371,36 +371,36 @@ var chill = function() {
hideableElements[i].style.display = "none"; hideableElements[i].style.display = "none";
} }
} }
} }
/** /**
* create an interaction between a checkbox and element to show if the * create an interaction between a checkbox and element to show if the
* checkbox is checked, or hide if the checkbox is not checked. * checkbox is checked, or hide if the checkbox is not checked.
* *
* The checkbox must have the data `data-display-target` with an id, * The checkbox must have the data `data-display-target` with an id,
* and the parts to show/hide must have the data `data-display-show-hide` * and the parts to show/hide must have the data `data-display-show-hide`
* with the same value. * with the same value.
* *
* Example : * Example :
* *
* ``` * ```
* <input data-display-target="export_abc" value="1" type="checkbox"> * <input data-display-target="export_abc" value="1" type="checkbox">
* *
* <div data-display-show-hide="export_abc"> * <div data-display-show-hide="export_abc">
* <!-- your content here will be hidden / shown according to checked state --> * <!-- your content here will be hidden / shown according to checked state -->
* </div> * </div>
* ``` * ```
* *
* Hint: for forms in symfony, you could use the `id` of the form element, * Hint: for forms in symfony, you could use the `id` of the form element,
* accessible through `{{ form.vars.id }}`. This id should be unique. * accessible through `{{ form.vars.id }}`. This id should be unique.
* *
* *
* @returns {undefined} * @returns {undefined}
*/ */
function listenerDisplayCheckbox() { function listenerDisplayCheckbox() {
var elements = document.querySelectorAll("[data-display-target]"); var elements = document.querySelectorAll("[data-display-target]");
for (let i=0; i < elements.length; i = i+1) { for (let i=0; i < elements.length; i = i+1) {
elements[i].addEventListener("change", function(e) { elements[i].addEventListener("change", function(e) {
_displayHideTargetWithCheckbox(e.target); _displayHideTargetWithCheckbox(e.target);
@ -421,3 +421,5 @@ var chill = function() {
listenerDisplayCheckbox: listenerDisplayCheckbox, listenerDisplayCheckbox: listenerDisplayCheckbox,
}; };
} (); } ();
export { chill };

View File

@ -1,4 +1,6 @@
// YOUR CUSTOM SCSS // YOUR CUSTOM SCSS
@import 'custom/config/colors';
@import 'custom/config/variables';
@import 'custom/timeline'; @import 'custom/timeline';
@import 'custom/mixins/entity'; @import 'custom/mixins/entity';
@import 'custom/activity'; @import 'custom/activity';
@ -11,7 +13,7 @@
@import 'custom/flash_messages'; @import 'custom/flash_messages';
html,body { html,body {
min-height:100%; min-height:100%;
font-family: 'Open Sans'; font-family: 'Open Sans';
} }
@ -83,9 +85,9 @@ ul.custom_fields.choice li {
font-family: 'Open Sans'; font-family: 'Open Sans';
font-weight: 300; font-weight: 300;
} }
a { a {
color: white; color: white;
text-decoration: underline; text-decoration: underline;
} }
} }
@ -97,7 +99,7 @@ ul.custom_fields.choice li {
display: inline-block; display: inline-block;
text-align: center; text-align: center;
} }
.separator { .separator {
margin-left: 0.2em; margin-left: 0.2em;
margin-right: 0.2em; margin-right: 0.2em;
@ -107,7 +109,7 @@ ul.custom_fields.choice li {
.open_sansbold { .open_sansbold {
font-family: 'Open Sans'; font-family: 'Open Sans';
font-weight: bold; font-weight: bold;
} }
@ -140,21 +142,21 @@ div.input_with_post_text input {
dl.chill_report_view_data, dl.chill_report_view_data,
dl.chill_view_data { dl.chill_view_data {
dt { dt {
margin-top: 1.5em; margin-top: 1.5em;
color: $chill-blue; color: $chill-blue;
} }
dd { dd {
padding-left: 1.5em; padding-left: 1.5em;
margin-top: 0.2em; margin-top: 0.2em;
ul { ul {
padding-left: 0; padding-left: 0;
} }
} }
} }
@ -164,13 +166,13 @@ blockquote.chill-user-quote {
padding: 0.5em 10px; padding: 0.5em 10px;
quotes: "\201C""\201D""\2018""\2019"; quotes: "\201C""\201D""\2018""\2019";
background-color: $chill-llight-gray; background-color: $chill-llight-gray;
p { display: inline; } p { display: inline; }
} }
.chill-no-data-statement { .chill-no-data-statement {
font-style: italic; font-style: italic;
} }

View File

@ -1,5 +1,5 @@
{# {#
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop> <info@champs-libres.coop> / <http://www.champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -22,19 +22,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
<title>{{ installation.name }} - {% block title %}{% endblock %}</title> <title>{{ installation.name }} - {% block title %}{% endblock %}</title>
<link rel="shortcut icon" href="/bundles/chillmain/img/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="/bundles/chillmain/img/favicon.ico" type="image/x-icon">
{% stylesheets output="css/all.css" filter="cssrewrite" <!-- {% stylesheets output="css/all.css" filter="cssrewrite"
"bundles/chillmain/css/scratch.css" "bundles/chillmain/css/scratch.css"
"bundles/chillmain/css/chillmain.css" "bundles/chillmain/css/chillmain.css"
"bundles/chillmain/css/select2/select2.css" "bundles/chillmain/css/select2/select2.css"
"bundles/chillmain/fonts/OpenSans/OpenSans.css" "bundles/chillmain/fonts/OpenSans/OpenSans.css"
"bundles/chillmain/css/pikaday.css" %} "bundles/chillmain/css/pikaday.css" %}
<link rel="stylesheet" href="{{ asset_url }}"/> <link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %} {% endstylesheets %} -->
<link rel="stylesheet" href="{{ asset('build/chill.css') }}"/>
{% block css%}<!-- nothing added to css -->{% endblock %} {% block css%}<!-- nothing added to css -->{% endblock %}
</head> </head>
@ -107,7 +107,7 @@
</span> </span>
</div> </div>
{% endfor %} {% endfor %}
{% for flashMessage in app.session.flashbag.get('error') %} {% for flashMessage in app.session.flashbag.get('error') %}
<div class="grid-8 centered error flash_message"> <div class="grid-8 centered error flash_message">
<span> <span>
@ -115,14 +115,14 @@
</span> </span>
</div> </div>
{% endfor %} {% endfor %}
{% for flashMessage in app.session.flashbag.get('notice') %} {% for flashMessage in app.session.flashbag.get('notice') %}
<div class="grid-8 centered notice flash_message"> <div class="grid-8 centered notice flash_message">
<span> <span>
{{ flashMessage|raw }} {{ flashMessage|raw }}
</span> </span>
</div> </div>
{% endfor %} {% endfor %}
{% block content %} {% block content %}
<div class="container"> <div class="container">
@ -137,12 +137,12 @@
</form> </form>
</div> </div>
</div> </div>
<div class="homepage_widget"> <div class="homepage_widget">
{{ chill_widget('homepage', {} ) }} {{ chill_widget('homepage', {} ) }}
</div> </div>
{% endblock %} {% endblock %}
</div> </div>
{% endblock %} {% endblock %}
</div> </div>
@ -150,8 +150,8 @@
<p>{{ 'This program is free software: you can redistribute it and/or modify it under the terms of the <strong>GNU Affero General Public License</strong>'|trans|raw }} <p>{{ 'This program is free software: you can redistribute it and/or modify it under the terms of the <strong>GNU Affero General Public License</strong>'|trans|raw }}
<br/> <a href="https://{{ app.request.locale }}.wikibooks.org/wiki/Chill">{{ 'User manual'|trans }}</a></p> <br/> <a href="https://{{ app.request.locale }}.wikibooks.org/wiki/Chill">{{ 'User manual'|trans }}</a></p>
</footer> </footer>
{% javascripts output="js/libs.js" <!-- {% javascripts output="js/libs.js"
"bundles/chillmain/js/jquery.js" "bundles/chillmain/js/jquery.js"
"bundles/chillmain/js/moment.js" "bundles/chillmain/js/moment.js"
"bundles/chillmain/js/pikaday/pikaday.js" "bundles/chillmain/js/pikaday/pikaday.js"
@ -159,7 +159,9 @@
"bundles/chillmain/js/pikaday/plugins/pikaday.jquery.js" "bundles/chillmain/js/pikaday/plugins/pikaday.jquery.js"
"bundles/chillmain/js/chill.js" %} "bundles/chillmain/js/chill.js" %}
<script src="{{ asset_url }}" type="text/javascript"></script> <script src="{{ asset_url }}" type="text/javascript"></script>
{% endjavascripts %} {% endjavascripts %} -->
<script type="text/javascript" src="{{ asset('build/chill.js') }}"></script>
<script type="text/javascript"> <script type="text/javascript">
chill.initPikaday('{{ app.request.locale }}'); chill.initPikaday('{{ app.request.locale }}');