Merge branch 'PHRAS-1745_PORT_custom_links' into PHRAS-1735_add_git_log

# Conflicts:
#	.bowerrc
This commit is contained in:
Mike Ng
2018-01-08 16:37:28 +04:00
26 changed files with 1309 additions and 272 deletions

View File

@@ -0,0 +1,14 @@
<tr>
<td>{{ form_widget(form.linkName) }}</td>
<td>{{ form_widget(form.linkLanguage) }}</td>
<td>{{ form_widget(form.linkUrl) }}</td>
<td>{{ form_widget(form.linkLocation) }}</td>
<td>{{ form_widget(form.linkOrder) }}</td>
<td>{{ form_widget(form.linkBold, { 'attr': {'style' : 'margin-top:0', 'class': 'link_check_box'} }) }}</td>
<td>{{ form_widget(form.linkColor, { 'attr': {'class': 'link-color'} }) }}</td>
<td>
<button class="btn btn-default close-row">
<span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span>
</button>
</td>
</tr>

View File

@@ -8,6 +8,7 @@
{% endblock %}
{% block stylesheet %}
<link rel="stylesheet" href="/bower_components/jquery-simplecolorpicker/jquery.simplecolorpicker.css">
<link type="text/css" rel="stylesheet" href="/assets/admin/css/admin{% if not app.debug %}.min{% endif %}.css" />
{% endblock %}

View File

@@ -34,23 +34,36 @@
{{ form_start(form, {'method': 'POST', 'action' : path('setup_display_globals'), 'attr': {'class' : 'form-horizontal'}}) }}
{{ form_errors(form) }}
{% for daform in form %}
<fieldset>
<legend>{{ daform.vars['label'] }}</legend>
{% for formdata in daform %}
<div class="control-group">
{{ form_errors(formdata) }}
{{ form_label(formdata, null, { 'label_attr': {'class' : 'control-label'} } ) }}
<div class="controls">
{{ form_widget(formdata, {'attr': {'class': 'input-xxlarge'}}) }}
</div>
{% if daform.vars['label'] != null %}
<fieldset>
<legend>{{ daform.vars['label'] }}</legend>
{% for formdata in daform %}
<div class="control-group">
{{ form_errors(formdata) }}
{{ form_label(formdata, null, { 'label_attr': {'class' : 'control-label'} } ) }}
<div class="controls">
{{ form_widget(formdata, {'attr': {'class': 'input-xxlarge'}}) }}
</div>
<div>{{ formdata.vars['help_message'] }}</div>
{{ form_rest(formdata) }}
</div>
{% endfor %}
{{ form_rest(daform) }}
</fieldset>
<div>{{ formdata.vars['help_message'] }}</div>
{{ form_rest(formdata) }}
</div>
{% endfor %}
{{ form_rest(daform) }}
</fieldset>
{% endif %}
{% endfor %}
<legend>{{ "setup::custom-link:title-custom-link" | trans }}</legend>
<table class="links" id="custom-link-table"
data-prototype="{% filter escape %}{% include 'admin/custom_links.html.twig' with {'form': form['custom-links'].vars.prototype} %}{% endfilter %}">
<tbody>
{% for links in form['custom-links'] %}
{% include 'admin/custom_links.html.twig' with {'form': links} %}
{% endfor %}
</tbody>
</table>
<button id="add-row" class="btn btn-success">{{ "setup::custom-link:add-link" | trans }}</button>
<div style="clear: both;"></div>
<div class="well well-large">
<div style="max-width: 400px;margin: 0 auto 10px;">
<input type="submit" class="btn btn-primary btn-block btn-large" value="{{ 'boutton::valider' | trans }}"/>
@@ -58,12 +71,26 @@
</div>
{{ form_end(form) }}
<script type="text/javascript" src="/assets/vendors/jquery-simplecolorpicker/jquery.simplecolorpicker.js"></script>
<script type='text/javascript'>
{% autoescape false %}
$(document).ready(function() {
// use html5 fallback validation if browser do not support required attribute
var form = $("#GV_form");
var inputs = form.find("input, select, textarea");
var header = "<thead>" +
"<th>{{ "setup::custom-link:name-link" | trans }}</th>" +
"<th>{{ "setup::custom-link:language-link" | trans }}</th>" +
"<th>{{ "setup::custom-link:link-url" | trans }}</th>" +
"<th>{{ "setup::custom-link:location-link" | trans }}</th>" +
"<th>{{ "setup::custom-link:order-link" | trans }}</th>" +
"<th></th>" +
"<th></th>" +
"<th></th>" +
"</thead>";
// if required not supported, emulate it
if (!Modernizr.input.required) {
form.bind("submit", function (event) {
@@ -95,6 +122,71 @@
}
});
}
// Get the ul that holds the collection of links
$collectionHolder = $('table.links');
$collectionHolder.data('index', $collectionHolder.find(':input').length);
if ($collectionHolder.find('tbody tr').length > 0) {
$("#custom-link-table").append(header);
}
$('select.link-color').simplecolorpicker({picker: true});
_.each($('select.link-color'), function (element) {
updateSelectColor($(element).siblings(), $(element).val());
updateInputNameColor($(element).parent().siblings(':first').find("input"), $(element).val());
});
$("#add-row").click(function (e) {
e.preventDefault();
if ($collectionHolder.find('tbody tr').length == 0) {
$("#custom-link-table").append(header);
}
addTagForm($collectionHolder);
});
function addTagForm($collectionHolder) {
// Get the data-prototype
var prototype = $collectionHolder.data('prototype');
// get the new index
var index = $collectionHolder.data('index');
var newForm = prototype;
newForm = newForm.replace(/__name__/g, index);
// increase the index with one for the next item
$collectionHolder.data('index', index + 1);
$collectionHolder.append(newForm);
$('select.link-color').simplecolorpicker({picker: true});
_.each($('select.link-color'), function (element) {
updateSelectColor($(element).siblings(), $(element).val());
updateInputNameColor($(element).parent().siblings(':first').find("input"), $(element).val());
});
}
$("#custom-link-table").on('click', '.close-row', function () {
$(this).closest('tr').remove();
var rowCount = $('#custom-link-table tr').length;
//remove header if no more rows
if (rowCount <= 1) {
$("#custom-link-table").empty();
}
return false;
});
$("#custom-link-table").on('change', 'select.link-color', function () {
var element = $(this).parent().siblings(':first').find("input");
updateSelectColor($(this).siblings(), $(this).val());
updateInputNameColor(element, $(this).val());
});
function updateSelectColor(element, color) {
element.css("border", "none");
if (color === "") {
element.css("background", "url(/assets/common/images/icons/Bouton-couleur.png)");
} else {
element.css("background", color);
}
}
function updateInputNameColor(element, color) {
element.css("background-color", color);
if (color === "") {
element.css("color", "#555");
} else {
element.css("color", "#FFFFFF");
}
}
});
{% endautoescape %}
</script>

View File

@@ -25,6 +25,7 @@
<script type="text/javascript">
google.charts.load('42', {packages: ['corechart']});
</script>
<script type="text/javascript" src="/assets/vendors/underscore/underscore{% if not app.debug %}.min{% endif %}.js"></script>
{% block rss %}{% endblock %}
{% block javascript %}{% endblock %}
</head>

View File

@@ -1,5 +1,6 @@
<div id="mainMenu" class="">
<div class="PNB" style="right:auto;overflow:hidden;">
{% set configuration = app['conf'].get(['registry', 'custom-links']) %}
<div class="PNB menu-bar" style="right:auto;overflow:hidden;">
<ol>
<li>
<span class="title">
@@ -181,3 +182,50 @@
{% include 'prod/notifications.html.twig' %}
</div>
{% endif %}
<script type="text/javascript">
$(document).ready(function () {
// var key = 'help';
var configurationSettingLinks = {{ configuration|json_encode|raw }};
//seperate array based on location of link
var seperatedLinksByLocation = _.groupBy(configurationSettingLinks, "linkLocation");
for (key in seperatedLinksByLocation) {
if (key === 'navigation-bar') {
var sortedCustomLinks = _.sortBy(seperatedLinksByLocation[key], 'linkOrder');
_.each(sortedCustomLinks, function (linksData) {
if (linksData.linkLanguage == 'all' || linksData.linkLanguage === '{{ app['locale'] }}') {
var styleAttr = "";
styleAttr += linksData.linkColor ? "color: " + linksData.linkColor + ";" : "";
styleAttr += linksData.linkBold == true ? "font-weight: bold;" : "";
var spanElement = $('<span />').attr('style', styleAttr).html(linksData.linkName);
var links = '<li><a target="_blank" href="' + linksData.linkUrl + '">' +
spanElement.prop("outerHTML") + '</a></li>';
$('#mainMenu .menu-bar ol').append(links);
}
});
} else if (key === 'help-menu') {
var sortedCustomLinks = _.sortBy(seperatedLinksByLocation[key], 'linkOrder');
_.each(sortedCustomLinks, function (linksData) {
if (linksData.linkLanguage == 'all' || linksData.linkLanguage === '{{ app['locale'] }}') {
var styleAttr = "";
styleAttr += linksData.linkColor ? "color: " + linksData.linkColor + ";" : "";
styleAttr += linksData.linkBold == true ? "font-weight: bold;" : "";
var spanElement = $('<span />').attr('style', styleAttr).html(linksData.linkName);
var links = '<div title="" class="context-menu-item menu3-custom-item">' +
'<div style="" class="context-menu-item-inner">' +
'<a target="_blank" href="' + linksData.linkUrl + '">' +
spanElement.prop("outerHTML") + '</a></div></div>';
$('.helpcontextmenu .context-menu-theme-vista').append(links);
}
});
}
}
});
</script>