Enhance register classic collection multiselect

This commit is contained in:
Nicolas Le Goff
2013-06-10 13:42:40 +02:00
parent 690a1543db
commit e89c502259
6 changed files with 79 additions and 11 deletions

View File

@@ -23,6 +23,7 @@
"i18next": "~1.6",
"sinon": "~1.7",
"sinon-chai": "~2.4",
"js-fixtures": "https://github.com/badunk/js-fixtures/archive/master.zip"
"js-fixtures": "https://github.com/badunk/js-fixtures/archive/master.zip",
"bootstrap-multiselect": "https://github.com/davidstutz/bootstrap-multiselect.git"
}
}

View File

@@ -74,30 +74,48 @@ class PhraseaRegisterForm extends AbstractType
$builder->add('provider-id', 'hidden');
require_once($this->app['phraseanet.registry']->get('GV_RootPath') . 'lib/classes/deprecated/inscript.api.php');
$choices = array();
$baseIds = array();
foreach (\giveMeBases($this->app) as $sbas_id => $baseInsc) {
if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript']) {
if ($baseInsc['Colls']) {
foreach ($baseInsc['Colls'] as $collId => $collName) {
$baseIds[\phrasea::baseFromColl($sbas_id, $collId, $this->app)] = $collName;
$baseId = \phrasea::baseFromColl($sbas_id, $collId, $this->app);
$sbasName= \phrasea::sbas_names($sbas_id, $this->app);
if (!isset($choices[$sbasName])) {
$choices[$sbasName] = array();
}
$choices[$sbasName][$baseId] = \phrasea::bas_labels($baseId, $this->app);
$baseIds[] = $baseId;
}
}
if ($baseInsc['CollsCGU']) {
foreach ($baseInsc['CollsCGU'] as $collId => $collName) {
$baseIds[\phrasea::baseFromColl($sbas_id, $collId, $this->app)] = $collName;
$baseId = \phrasea::baseFromColl($sbas_id, $collId, $this->app);
$sbasName= \phrasea::sbas_names($sbas_id, $this->app);
if (!isset($choices[$sbasName])) {
$choices[$sbasName] = array();
}
$choices[$sbasName][$baseId] = \phrasea::bas_labels($baseId, $this->app);
$baseIds[] = $baseId;
}
}
}
}
$builder->add('collections', 'choice', array(
'choices' => $baseIds,
'choices' => $choices,
'multiple' => true,
'expanded' => true,
'expanded' => false,
'constraints' => array(
new Assert\Choice(array(
'choices'=>array_keys($baseIds),
'choices' => array_flip($baseIds),
'minMessage' => _('You must select at least {{ limit }} collection'),
'multiple' => true,
'min' => 1,

View File

@@ -21,6 +21,7 @@ $groups = array(
'//assets/angular/angular.js',
'//assets/angular-ui/build/angular-ui.js',
'//assets/bootstrap-switch/static/js/bootstrapSwitch.js',
'//assets/bootstrap-multiselect/js/bootstrap-multiselect.js',
'//assets/underscore/underscore.js'
),
'client' => array(

View File

@@ -1,6 +1,7 @@
{% extends "login/layout/sidebar-layout.html.twig" %}
{% import "login/common/macros.html.twig" as auth_macro %}
{% import "common/macros.html.twig" as macro %}
{% block title %}
{% trans "Register" %}
@@ -25,13 +26,10 @@
<div class="span12">
{{ auth_macro.flashes() }}
<form
ng-controller="registerFormCtrl"
novalidate
name="registerForm"
ng-submit="submit();"
method="POST"
action="{{ path("login_register_classic") }}"
check-form-submission
>
<div class="row-fluid">
<div class="span12">
@@ -85,11 +83,18 @@
</div>
</div>
<div class="row-fluid">
<div class="span12">
{{ form_row(form.collections) }}
</div>
</div>
{{ form_rest(form) }}
{% if recaptcha_display %}
<div class="row-fluid">
<div class="span12">
{{ macro.captcha() }}
{#{{ macro.captcha() }}#}
</div>
</div>
{% endif %}

View File

@@ -29,3 +29,17 @@ require.config({
require(["apps/login/home/app"], function(App) {
App.initialize();
});
// close alerts
$(document).ready(function() {
$(document).on("click", ".alert .alert-block-close a", function(e){
e.preventDefault();
$(this).closest('.alert').alert('close');
return false;
});
$("select[multiple='multiple']").multiselect({
buttonWidth : "100%",
buttonClass: 'btn btn-inverse'
});
});

View File

@@ -712,6 +712,35 @@ form[name=desktop_code] {
margin-top:30px;
}
form[name=registerForm] .btn-group {
width: 100%;
}
form[name=registerForm] .multiselect {
text-align: left;
}
form[name=registerForm] .multiselect-container {
width: 99%;
}
form[name=registerForm] .multiselect-container li.active label{
color: @black;
}
form[name=registerForm] .multiselect b.caret {
float: right;
}
form[name=registerForm] .multiselect-group {
font-weight: bold;
text-decoration: underline;
}
form[name=registerForm] .multiselect-all label {
font-weight: bold;
}
/** IE Fixes */
.lt-ie8 authentication-sidebar-language .caret {