}
/**
- * monter un groupe motif dans la liste des groupes motif
- * @param groupeMotif
- * @param pref
- * @return les 2 groupeinfos modifiés par l'opération
+ * Permet de déplacer un groupe de motif
+ * @param groupeADeplacer
+ * @param groupeARemplacer
+ * @return la liste des objets GroupeMotif modifiés
*/
+ public List<GroupeMotif> deplaceGroupeMotif(GroupeMotif groupeADeplacer,
+ GroupeMotif groupeARemplacer,
+ PreferencesEtablissementAbsences pref
+ ) {
+
+ Integer groupeADeplacerOrdre = groupeADeplacer.ordre
+ Integer groupeARemplacerOrdre = groupeARemplacer.ordre
+
+ if (groupeADeplacerOrdre == groupeARemplacerOrdre) {
+ throw new IllegalStateException("On ne peut pas remplacer un groupe par lui-même.")
+ }
+
+
+ List<GroupeMotif> resultat = []
+
+ // on remonte un groupe de motifs
+ if (groupeARemplacerOrdre < groupeADeplacerOrdre) {
+
+ resultat = GroupeMotif.withCriteria {
+ eq('preferencesEtablissement', pref)
+ ge('ordre', groupeARemplacerOrdre)
+ order('ordre')
+ }
+
+ deplacerGroupe(
+ resultat,
+ groupeADeplacer,
+ 0
+ )
+
+
+ modifierNumeroOrdreAllGroupe(groupeARemplacerOrdre, resultat)
+
+ }
+
+ // on descend un groupe de motifs
+ if (groupeARemplacerOrdre > groupeADeplacerOrdre) {
+
+ resultat = GroupeMotif.withCriteria {
+ eq('preferencesEtablissement', pref)
+ ge('ordre', groupeADeplacerOrdre)
+ order('ordre')
+ }
+
+ Integer positionARemplacer = resultat.indexOf(groupeARemplacer)
+
+ deplacerGroupe(
+ resultat,
+ groupeADeplacer,
+ positionARemplacer
+ )
+
+
+ modifierNumeroOrdreAllGroupe(groupeADeplacerOrdre, resultat)
+
+ }
+
+ return resultat
+
+ }
+
+ /**
+ * Modifie le numéro d'ordre de tous les groupes motif
+ * @param ordre : numéro de départ
+ * @param resultat
+ */
+ private void modifierNumeroOrdreAllGroupe(int ordre, List<GroupeMotif> resultat) {
+
+ Integer nouveauNumeroOrdre = ordre
+
+ resultat.each {GroupeMotif groupe ->
+ nouveauNumeroOrdre++
+ modifieOrdreGroupe(
+ groupe,
+ nouveauNumeroOrdre
+ )
+
+ }
+ }
+
+ private void deplacerGroupe(List<GroupeMotif> allGroupe, GroupeMotif groupeMotif, Integer index){
+ allGroupe.remove(groupeMotif)
+ allGroupe.add(index, groupeMotif)
+
+ }
+
+ private void modifieOrdreGroupe(GroupeMotif groupeMotif, Integer ordre) {
+ groupeMotif.ordre = ordre
+ groupeMotif.save(flush: true, failOnError: true)
+ }
+
+/**
+ * monter un groupe motif dans la liste des groupes motif
+ * @param groupeMotif
+ * @param pref
+ * @return les 2 groupeinfos modifiés par l'opération
+ */
public List<GroupeMotif> monterGroupeMotif(GroupeMotif groupeMotif, PreferencesEtablissementAbsences pref) {
Integer numeroOrdrePrecedent = getNumeroOrdrePrecedent(
}
- /**
- * descendre un groupe motif dans la liste des groupes motif
- * @param groupeMotif
- * @param pref
- * @return les 2 groupeinfos modifiés par l'opération
- */
+/**
+ * descendre un groupe motif dans la liste des groupes motif
+ * @param groupeMotif
+ * @param pref
+ * @return les 2 groupeinfos modifiés par l'opération
+ */
public List<GroupeMotif> descendreGroupeMotif(GroupeMotif groupeMotif, PreferencesEtablissementAbsences pref) {
Integer numeroOrdreSuivant = getNumeroOrdreSuivant(
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ ~ This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ ~
+ ~ Lilie is free software. You can redistribute it and/or modify since
+ ~ you respect the terms of either (at least one of the both license) :
+ ~ - under the terms of the GNU Affero General Public License as
+ ~ published by the Free Software Foundation, either version 3 of the
+ ~ License, or (at your option) any later version.
+ ~ - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ ~ License, or any later version
+ ~
+ ~ There are special exceptions to the terms and conditions of the
+ ~ licenses as they are applied to this software. View the full text of
+ ~ the exception in file LICENSE.txt in the directory of this software
+ ~ distribution.
+ ~
+ ~ Lilie is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ~ Licenses for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ and the CeCILL-C along with Lilie. If not, see :
+ ~ <http://www.gnu.org/licenses/> and
+ ~ <http://www.cecill.info/licences.fr.html>.
+ -->
+<databaseChangeLog
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
+
+ <changeSet id="1" author="othe">
+ <comment>Suppression contrainte sur ordre des groupe motif</comment>
+
+ <dropUniqueConstraint tableName="groupe_motif"
+ schemaName="enttemps"
+ constraintName="uk_ordre_preference_etablissement_absences_id" />
+
+ </changeSet>
+
+ <changeSet id="2" author="othe">
+ <comment>
+ Reconstruction de la contrainte, pour qu'elle soit vérifié en fin de commit
+ </comment>
+
+ <sql>
+ ALTER TABLE enttemps.groupe_motif
+ ADD CONSTRAINT uk_ordre_preference_etablissement_absences_id UNIQUE(ordre , preference_etablissement_absences_id ) deferrable initially deferred;
+ </sql>
+
+ </changeSet>
+
+
+</databaseChangeLog>
<include file="changelogs/securite/2013-03-12-0025761.xml"/>
<include file="changelogs/scolarite/2013-03-11-0026308.xml"/>
<include file="changelogs/scolarite/2013-03-14-0025997.xml"/>
+ <include file="changelogs/scolarite/2013-03-15-0025997.xml"/>
</databaseChangeLog>
)
}
+ def deplacer = {
+
+ Long groupeARemplacer = Long.parseLong(params.aremplacerId)
+ Long groupeADeplacer = Long.parseLong(params.adeplacerId)
+
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences = getPreferencesEtablissementCourant()
+
+ List<GroupeMotif> allGroupeMotifModifie = groupeMotifService.deplaceGroupeMotif(
+ GroupeMotif.get(groupeADeplacer),
+ GroupeMotif.get(groupeARemplacer),
+ preferencesEtablissementAbsences
+ )
+
+ // id/ordre
+ Map resultat = [
+ success: true,
+ message: message(
+ code: 'absences.parametrage.groupemotif.deplacement.succes'
+ ),
+ data: []
+ ]
+
+ allGroupeMotifModifie.each { GroupeMotif groupeMotif ->
+
+ resultat.data << [
+ 'id': groupeMotif.id,
+ 'ordre': groupeMotif.ordre,
+ ]
+
+ }
+
+ render resultat as JSON
+ }
+
/**
* Convertion de l'objet contenant l'arbre des motif en JSON
* @param arbreMotifInfo
Map resultat = [
id: "$groupeMotif.id",
text: groupeMotif.libelle,
- draggable: false,
+ draggable: true,
ordre: groupeMotif.ordre
]
leaf: true,
editable: false,
uiProvider: "col",
- iconCls:"no-icon"
+ iconCls: "no-icon"
]
}
--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.absences.parametrage.motif
+
+import org.lilie.services.eliot.absences.AbstractAbsencesController
+import org.lilie.services.eliot.absences.GroupeMotif
+import org.lilie.services.eliot.parametrages.motifs.GroupeMotifException
+import org.lilie.services.eliot.parametrages.motifs.GroupeMotifDeleteException
+import org.lilie.services.eliot.absences.Motif
+import org.lilie.services.eliot.parametrages.motifs.MotifException
+import org.lilie.services.eliot.parametrages.motifs.GroupeMotifService
+import org.lilie.services.eliot.parametrages.motifs.MotifDeleteException
+import org.lilie.services.eliot.absences.PreferencesEtablissementAbsences
+import org.lilie.services.eliot.absences.page.Page
+import grails.converters.JSON
+import org.lilie.services.eliot.parametrages.motifs.MotifDeleteUtiliseException
+import org.lilie.services.eliot.parametrages.motifs.GroupeMotifDeleteUtiliseException
+import org.lilie.services.eliot.absences.fonctionnalites.AbsencesFonctionnalite
+import org.lilie.services.eliot.annuaire.SecuriteSession
+import org.lilie.services.eliot.urllabel.breadcrumbs.BreadCrumbsItemInfo
+import org.lilie.services.eliot.urllabel.UrlLabelInfo
+
+@SuppressWarnings('ReturnNullFromCatchBlock')
+class ParametrageMotifController extends AbstractAbsencesController {
+
+ GroupeMotifService groupeMotifService
+
+ def index = {
+
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences = getPreferencesEtablissementCourant()
+
+ List<GroupeMotif> allGroupeMotif =
+ groupeMotifService.findAllGroupeMotifByPreferencesEtablissement(preferencesEtablissementAbsences)
+
+ // construction du modèle
+ Map modele = prepareBaseModele(Page.PARAMETRAGE_MOTIFS)
+
+ modele.preferencesEtablissement = preferencesEtablissementAbsences
+
+ modele.arbreMotif = allGroupeMotifVersJson(allGroupeMotif)
+
+ render(
+ view: '/parametrage/motifs/motif',
+ model: modele
+ )
+ }
+
+ def deplacer = {
+
+ Long groupeARemplacer = Long.parseLong(params.aremplacerId)
+ Long groupeADeplacer = Long.parseLong(params.adeplacerId)
+
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences = getPreferencesEtablissementCourant()
+
+ List<GroupeMotif> allGroupeMotifModifie = groupeMotifService.deplaceGroupeMotif(
+ GroupeMotif.get(groupeADeplacer),
+ GroupeMotif.get(groupeARemplacer),
+ preferencesEtablissementAbsences
+ )
+
+ // id/ordre
+ Map resultat = [
+ success: true,
+ message: message(
+ code: 'absences.parametrage.groupemotif.deplacement.succes'
+ ),
+<<<<<<< HEAD
+ data: []
+=======
+ data: [
+ [id: 1, ordre: 10],
+ [id: 2, ordre: 11],
+ [id: 3, ordre: 12],
+ [id: 4, ordre: 13]
+ ]
+>>>>>>> 5562580... 0025997: Paramétrage des motifs pour la prise en compte dans les bulletins et les statistiques
+ ]
+
+ allGroupeMotifModifie.each { GroupeMotif groupeMotif ->
+
+ resultat.data << [
+ 'id': groupeMotif.id,
+ 'ordre': groupeMotif.ordre,
+ ]
+
+ }
+
+ render resultat as JSON
+ }
+
+ /**
+ * Convertion de l'objet contenant l'arbre des motif en JSON
+ * @param arbreMotifInfo
+ * @return
+ */
+ private JSON allGroupeMotifVersJson(List<GroupeMotif> allGroupeMotif) {
+
+ List resultat = []
+
+ allGroupeMotif.each {GroupeMotif groupeMotif ->
+ resultat << groupeMotifToMap(groupeMotif)
+ }
+
+ return resultat as JSON
+
+ }
+
+ /**
+ * Convertion d'un groupe motif pour l'interface
+ * @param noeudMotifInfo
+ * @return
+ */
+ private Map groupeMotifToMap(GroupeMotif groupeMotif) {
+
+ Map resultat = [
+ id: "$groupeMotif.id",
+ text: groupeMotif.libelle,
+ draggable: true,
+ ordre: groupeMotif.ordre
+ ]
+
+ // récupération des données enfants
+ List motifs = []
+
+ groupeMotif.motifs.each {Motif motif ->
+ motifs << [
+ id: "$motif.id",
+ nom: motif.libelle,
+ draggable: false,
+ couleur: motif.couleur,
+ dispoBulletin: motif.dispoBulletin,
+ dispoStats: motif.dispoStats,
+ leaf: true,
+ editable: false,
+ uiProvider: "col",
+ iconCls: "no-icon"
+ ]
+ }
+
+ resultat.children = motifs
+
+ return resultat
+
+ }
+
+
+ /**
+ * Action de création d'un groupe de motif
+ */
+ def creerGroupeMotif = {
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+ String libelle = params.libelle
+ log.debug("creerGroupeMotif:" + libelle)
+ SecuriteSession securiteSession = getSecuriteSession()
+ String etablissementIdExterne = securiteSession.etablissementCourant.idExterne
+
+ def prefEtab = getPreferencesEtablissementForIdExterne(
+ etablissementIdExterne,
+ true
+ )
+
+ GroupeMotif groupeMotif
+ try {
+ groupeMotif = groupeMotifService.creerGroupeMotif(
+ prefEtab,
+ libelle,
+ securiteSession
+ )
+ }
+ catch (GroupeMotifException e) {
+ render([
+ success: false,
+ errorMsg: message(code: e.codeMessage)
+ ] as JSON)
+ return
+ }
+
+ Map leGroupeMotifJSON = [
+ 'nom': groupeMotif?.libelle,
+ 'id': groupeMotif?.id,
+ 'success': true
+ ]
+
+ render leGroupeMotifJSON as JSON
+ }
+
+ /**
+ * Action de modification d'un groupe de motif
+ */
+ def modifierGroupeMotif = {
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+ SecuriteSession securiteSession = getSecuriteSession()
+
+ String libelle = params.libelle
+ Long id = Long.parseLong(params.idGrpMotif)
+ Integer ordre = Integer.parseInt(params.ordre)
+
+ log.debug("modifierGroupeMotif:" + libelle + ", id=" + id)
+
+ GroupeMotif groupeMotif
+ try {
+ groupeMotif = groupeMotifService.modifieGroupeMotif(
+ securiteSession,
+ id,
+ libelle,
+ ordre
+ )
+ }
+ catch (GroupeMotifException e) {
+ render([
+ success: false,
+ errorMsg: message(code: e.codeMessage)
+ ] as JSON)
+ return
+ }
+
+ Map leGroupeMotifJSON = [
+ 'nom': groupeMotif?.libelle,
+ 'id': groupeMotif?.id,
+ 'success': true
+ ]
+
+ render leGroupeMotifJSON as JSON
+ }
+
+ /**
+ * Action de suppression d'un groupe de motifs
+ */
+ def supprimerGroupeMotif = {
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+
+ SecuriteSession securiteSession = getSecuriteSession()
+
+ Long id = Long.parseLong(params.idGrpMotif)
+ if (log.isDebugEnabled()) {
+ log.debug("supprimerGroupeMotif: id=" + id)
+ }
+ Map resultat
+ try {
+ groupeMotifService.supprimerGroupeMotif(id, securiteSession)
+ resultat = ['success': true]
+ } catch (GroupeMotifDeleteUtiliseException e) {
+ resultat = ['success': false, 'message': message([code: e.messageCode])]
+ } catch (GroupeMotifDeleteException e) {
+ log.error("Une erreur est surevenue lors de la suppression d'un GroupeMotif.", e)
+ resultat = ['success': false, 'message': message([code: e.messageCode])]
+ }
+
+ render resultat as JSON
+ }
+
+ def monterGroupeMotif = {
+
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences = getPreferencesEtablissementCourant()
+ Long id = Long.parseLong(params.id)
+
+ Map resultat
+ try {
+ List<GroupeMotif> groupesModifies = groupeMotifService.monterGroupeMotif(
+ GroupeMotif.load(id),
+ preferencesEtablissementAbsences
+ )
+ resultat = ['success': true]
+
+ if (groupesModifies) {
+ resultat['groupe1'] = [
+ 'id': groupesModifies[0].id,
+ 'ordre': groupesModifies[0].ordre
+ ]
+
+ resultat['groupe2'] = [
+ 'id': groupesModifies[1].id,
+ 'ordre': groupesModifies[1].ordre
+ ]
+ }
+
+ }
+ catch (GroupeMotifException e) {
+ render([
+ success: false,
+ errorMsg: message(code: e.codeMessage)
+ ] as JSON)
+ return
+ }
+
+ render resultat as JSON
+
+ }
+
+ def descendreGroupeMotif = {
+
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences = getPreferencesEtablissementCourant()
+ Long id = Long.parseLong(params.id)
+
+ Map resultat
+ try {
+
+ List<GroupeMotif> groupesModifies = groupeMotifService.descendreGroupeMotif(
+ GroupeMotif.load(id),
+ preferencesEtablissementAbsences
+ )
+
+ resultat = ['success': true]
+
+ if (groupesModifies) {
+
+ resultat['groupe1'] = [
+ 'id': groupesModifies[0].id,
+ 'ordre': groupesModifies[0].ordre
+ ]
+
+ resultat['groupe2'] = [
+ 'id': groupesModifies[1].id,
+ 'ordre': groupesModifies[1].ordre
+ ]
+ }
+
+ }
+ catch (GroupeMotifException e) {
+ render([
+ success: false,
+ errorMsg: message(code: e.codeMessage)
+ ] as JSON)
+ return
+ }
+
+ render resultat as JSON
+
+ }
+
+ /**
+ * Action de création d'un motif
+ */
+ def creerMotif = {
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+ SecuriteSession securiteSession = getSecuriteSession()
+
+ String libelle = params.libelle
+ String couleur = params.couleur
+
+ Boolean dispoBulletin = true
+ if (params.dispoBulletin) {
+ dispoBulletin = Boolean.parseBoolean(params.dispoBulletin)
+ }
+
+ Boolean dispoStats = true
+ if (params.dispoBulletin) {
+ dispoStats = Boolean.parseBoolean(params.dispoStats)
+ }
+
+ Long id = Long.parseLong(params.idGroupe)
+
+ log.debug("creerMotif:" + libelle + ", id=" + id)
+
+ GroupeMotif grMotif = GroupeMotif.get(id)
+
+ Motif leMotif
+ try {
+ leMotif = motifService.creerMotif(
+ securiteSession,
+ grMotif,
+ libelle,
+ couleur,
+ dispoBulletin,
+ dispoStats
+ )
+ }
+ catch (MotifException e) {
+
+ render([
+ success: false,
+ errorMsg: message(code: e.codeMessage, args: [e.argsMessage])
+ ] as JSON)
+ return
+ }
+
+ Map leMotifJSON = [
+ 'nom': leMotif?.libelle,
+ 'id': leMotif?.id,
+ 'codeCouleur': leMotif?.couleur,
+ success: true
+ ]
+
+ render leMotifJSON as JSON
+ }
+
+ def modifierDispoMotif = {
+
+ try {
+
+ def allModifs = JSON.parse((String) params.motifs)
+
+ modifieAllDispoMotif(
+
+ (List) allModifs
+ )
+
+ } catch (MotifException e) {
+
+ render(
+ [
+ success: false,
+ errorMsg: message(code: e.codeMessage, args: [e.argsMessage])
+ ] as JSON
+ )
+ return
+ }
+
+ Map reponse = [
+ success: true
+ ]
+
+ render reponse as JSON
+
+ }
+
+ /**
+ * Modification des dispo de la liste de motifs
+ * @param motifs map correspondant à ce qui est envoyé en param en json
+ */
+ private void modifieAllDispoMotif(
+ List motifs
+ ) {
+
+ motifs.each {Map dispoMotif ->
+
+ Motif motif = Motif.load(dispoMotif.id)
+
+ motifService.modifieDisponibiliteMotif(
+ getSecuriteSession(),
+ motif,
+ dispoMotif.dispoBulletin,
+ dispoMotif.dispoStats
+ )
+
+ }
+
+ }
+
+ /**
+ * Action de modification d'un motif
+ */
+ def modifierMotif = {
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+ SecuriteSession securiteSession = getSecuriteSession()
+
+ String libelle = params.libelle
+ String couleur = params.couleur
+ Long idMotif = Long.parseLong(params.idMotif)
+ Long idGroupe = Long.parseLong(params.idGroupe)
+
+ log.debug("modifierMotif: idMotif=" + idMotif + ", idGroupe=" + idGroupe)
+
+ GroupeMotif motifAModifier = GroupeMotif.get(idGroupe)
+
+ Motif leMotif
+ try {
+ leMotif = motifService.modifieMotif(
+ securiteSession,
+ motifAModifier,
+ idMotif,
+ libelle,
+ couleur
+ )
+ }
+ catch (MotifException e) {
+ render(
+ [
+ success: false,
+ errorMsg: message(code: e.codeMessage, args: [e.argsMessage])
+ ] as JSON
+ )
+ return
+ }
+
+ Map leMotifJSON = [
+ 'nom': leMotif?.libelle,
+ 'id': leMotif?.id?.toString(),
+ 'codeCouleur': leMotif?.couleur,
+ success: true
+ ]
+
+ render leMotifJSON as JSON
+ }
+
+ /**
+ * Action de suppression d'un motif
+ */
+ def supprimerMotif = {
+ verificationDroitFonctionnalite(AbsencesFonctionnalite.PARAMETRAGE_MOTIF)
+ SecuriteSession securiteSession = getSecuriteSession()
+
+ Map resultat
+ Long id = Long.parseLong(params.idMotif)
+ log.debug("supprimerMotif: idMotif=$id")
+
+ try {
+ motifService.supprimerMotif(id, securiteSession)
+ resultat = ['success': true]
+ } catch (MotifDeleteUtiliseException e) {
+ resultat = ['success': false, 'message': message([code: e.messageCode])]
+ } catch (MotifDeleteException e) {
+ resultat = ['success': false, 'message': message([code: e.messageCode])]
+ }
+
+ render resultat as JSON
+ }
+
+ /**
+ * Retourne la représentation JSON de l'arbre des groupes de motifs / motifs
+ * pour l'établissement de l'acteur courrant
+ */
+ def listerMotifs = {
+ List lesGroupesMotifs
+ boolean listerTousMotifs = Boolean.parseBoolean(params?.listerTousMotifs)
+
+ PreferencesEtablissementAbsences preferencesEtablissement =
+ getPreferencesEtablissementCourant()
+
+ if (preferencesEtablissement.groupeMotifs.size() == 0) {
+ groupeMotifService.creerMotifsParDefault(preferencesEtablissement)
+ }
+
+ lesGroupesMotifs =
+ preferencesEtablissementAbsencesService.buildModelGroupeMotifForJason(
+ preferencesEtablissement,
+ listerTousMotifs
+ )
+
+ render lesGroupesMotifs as JSON
+ }
+
+ protected List<UrlLabelInfo> getBreadCrumbsInfo() {
+ List<UrlLabelInfo> breadCrumbsInfo = super.getBreadCrumbsInfo()
+ breadCrumbsInfo << new BreadCrumbsItemInfo(
+ codeLabel: 'absences.breadCrumbs.parametrage'
+ )
+ breadCrumbsInfo << new BreadCrumbsItemInfo(
+ codeLabel: 'absences.breadCrumbs.parametrage.motifs'
+ )
+ return breadCrumbsInfo
+
+ }
+
+}
absences.groupeMotifs.monter.echec=Le déplacement du groupe de motifs a échoué.
absences.groupeMotifs.descendre.succes=Le groupe de motifs a été déplacé avec succès.
absences.groupeMotifs.descendre.echec=Le déplacement du groupe de motifs a échoué.
+absences.groupeMotifs.deplacer.succes=Le groupe de motifs a été déplacé avec succès.
+absences.groupeMotifs.deplacer.echec=Le déplacement du groupe de motifs a échoué.
absences.groupeMotifs.supprimer.echec.motifutilise=La suppression du groupe de motifs est impossible car un des motifs est utilisé.
absences.groupeMotifs.fenetre.creerTitre=Créer un groupe de motifs
absences.parametrage.general.libelle.plageHoraireEtab=des plages horaires ouvertes de l'établissement
absences.parametrage.general.libelle.edtEleves=de l'emploi du temps réel des élèves
+absences.parametrage.groupemotif.deplacement.succes=Le groupe motif a été déplacé
+
#Libellés pour la page "Incident, punition et sanction"
absences.ips.libelle.typeIncidents=Types d'incident
absences.ips.libelle.typePunitions=Types de punition
<eliotjs:varLink name="urlSupprimerGrpMotif" action="supprimerGroupeMotif" controller="parametrageMotif"/>
<eliotjs:varLink name="urlMonterGrpMotif" action="monterGroupeMotif" controller="parametrageMotif"/>
<eliotjs:varLink name="urlDescendreGrpMotif" action="descendreGroupeMotif" controller="parametrageMotif"/>
-
<eliotjs:varLink name="urlModifierDispoMotif" action="modifierDispoMotif" controller="parametrageMotif"/>
+ <eliotjs:varLink name="urlDeplacerGrpMotif" action="deplacer" controller="parametrageMotif"/>
+
<eliotjs:varResource name="urlImageAdd16" dir="images" file="add16x16.gif"/>
<eliotjs:varResource name="urlImageEdit" dir="images" file="edit.png"/>
<eliotjs:varResource name="urlImageSupprimer" dir="images" file="delete.gif"/>
<eliotjs:varI18n name="grpMotifMonterEchec" code="absences.groupeMotifs.monter.echec"/>
<eliotjs:varI18n name="grpMotifDescendreSucces" code="absences.groupeMotifs.descendre.succes"/>
<eliotjs:varI18n name="grpMotifDescendreEchec" code="absences.groupeMotifs.descendre.echec"/>
+ <eliotjs:varI18n name="grpMotifDeplacerSucces" code="absences.groupeMotifs.deplacer.succes"/>
+ <eliotjs:varI18n name="grpMotifDeplacerEchec" code="absences.groupeMotifs.deplacer.echec"/>
</eliotjs:ns>
</eliotjs:ns>
-/*\r
- * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009\r
- * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).\r
- *\r
- * Lilie is free software. You can redistribute it and/or modify since\r
- * you respect the terms of either (at least one of the both license) :\r
- * - under the terms of the GNU Affero General Public License as\r
- * published by the Free Software Foundation, either version 3 of the\r
- * License, or (at your option) any later version.\r
- * - the CeCILL-C as published by CeCILL-C; either version 1 of the\r
- * License, or any later version\r
- *\r
- * There are special exceptions to the terms and conditions of the\r
- * licenses as they are applied to this software. View the full text of\r
- * the exception in file LICENSE.txt in the directory of this software\r
- * distribution.\r
- *\r
- * Lilie is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * Licenses for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * and the CeCILL-C along with Lilie. If not, see :\r
- * <http://www.gnu.org/licenses/> and\r
- * <http://www.cecill.info/licences.fr.html>.\r
- */\r
-\r
-package org.lilie.services.eliot.absences\r
-\r
-import grails.test.GrailsUnitTestCase\r
-import org.lilie.services.eliot.test.PopulationTestEtablissement\r
-import org.lilie.services.eliot.test.LocalInitDonneesCommunesTestService\r
-import org.lilie.services.eliot.scolarite.etablissement.PreferencesEtablissementAbsencesService\r
-\r
-/*\r
-@author sdim\r
-*/\r
-\r
-class GroupeMotifIntegrationTests extends GrailsUnitTestCase {\r
- PreferencesEtablissementAbsencesService preferencesEtablissementAbsencesService\r
- LocalInitDonneesCommunesTestService localInitDonneesCommunesTestService\r
- PreferencesEtablissementAbsences preferencesEtablissement\r
-\r
- protected void setUp() {\r
- super.setUp()\r
- preferencesEtablissement = preferencesEtablissementAbsencesService.\r
- getPreferencesEtablissementForEtablissement(\r
- localInitDonneesCommunesTestService.getEtablissement(\r
- PopulationTestEtablissement.ETABLISSEMENT_1)\r
- )\r
- }\r
-\r
- void testFirstSaveEver() {\r
- def groupeMotif = new GroupeMotif(\r
- preferencesEtablissement: preferencesEtablissement,\r
- libelle: 'Groupe motif 1',\r
- ordre: 0\r
- )\r
-\r
- assertNotNull groupeMotif.save()\r
- assertNotNull groupeMotif.id\r
-\r
- def foundGroupeMotif = GroupeMotif.get(groupeMotif.id)\r
- assertEquals 'Groupe motif 1', foundGroupeMotif.libelle\r
- }\r
-\r
- void testSaveAndUpdate() {\r
-\r
- def groupeMotif = new GroupeMotif(\r
- preferencesEtablissement: preferencesEtablissement,\r
- libelle: 'Groupe motif 1',\r
- ordre: 0\r
- )\r
-\r
- assertNotNull groupeMotif.save()\r
-\r
- def foundGroupeMotif = GroupeMotif.get(groupeMotif.id)\r
- foundGroupeMotif.libelle = 'Groupe motif 2'\r
- foundGroupeMotif.save()\r
-\r
- def editedGroupeMotif = GroupeMotif.get(groupeMotif.id)\r
- assertEquals 'Groupe motif 2', editedGroupeMotif.libelle\r
-\r
- }\r
-\r
- void testSaveThenDelete() {\r
-\r
- def groupeMotif = new GroupeMotif(\r
- preferencesEtablissement: preferencesEtablissement,\r
- libelle: 'Groupe motif 1',\r
- ordre: 0\r
- )\r
-\r
- assertNotNull groupeMotif.save()\r
-\r
- def foundGroupeMotif = GroupeMotif.get(groupeMotif.id)\r
- foundGroupeMotif.delete()\r
-\r
- assertFalse GroupeMotif.exists(foundGroupeMotif.id)\r
-\r
- }\r
-\r
-\r
-}\r
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+package org.lilie.services.eliot.absences
+
+import grails.test.GrailsUnitTestCase
+import org.lilie.services.eliot.test.PopulationTestEtablissement
+import org.lilie.services.eliot.test.LocalInitDonneesCommunesTestService
+import org.lilie.services.eliot.scolarite.etablissement.PreferencesEtablissementAbsencesService
+
+/*
+@author sdim
+*/
+
+class GroupeMotifIntegrationTests extends GrailsUnitTestCase {
+ PreferencesEtablissementAbsencesService preferencesEtablissementAbsencesService
+ LocalInitDonneesCommunesTestService localInitDonneesCommunesTestService
+ PreferencesEtablissementAbsences preferencesEtablissement
+
+ protected void setUp() {
+ super.setUp()
+ preferencesEtablissement = preferencesEtablissementAbsencesService.
+ getPreferencesEtablissementForEtablissement(
+ localInitDonneesCommunesTestService.getEtablissement(
+ PopulationTestEtablissement.ETABLISSEMENT_1)
+ )
+ }
+
+ void testFirstSaveEver() {
+ def groupeMotif = new GroupeMotif(
+ preferencesEtablissement: preferencesEtablissement,
+ libelle: 'Groupe motif 1',
+ ordre: 0
+ )
+
+ assertNotNull groupeMotif.save()
+ assertNotNull groupeMotif.id
+
+ def foundGroupeMotif = GroupeMotif.get(groupeMotif.id)
+ assertEquals 'Groupe motif 1', foundGroupeMotif.libelle
+ }
+
+ void testSaveAndUpdate() {
+
+ def groupeMotif = new GroupeMotif(
+ preferencesEtablissement: preferencesEtablissement,
+ libelle: 'Groupe motif 1',
+ ordre: 0
+ )
+
+ assertNotNull groupeMotif.save()
+
+ def foundGroupeMotif = GroupeMotif.get(groupeMotif.id)
+ foundGroupeMotif.libelle = 'Groupe motif 2'
+ foundGroupeMotif.save()
+
+ def editedGroupeMotif = GroupeMotif.get(groupeMotif.id)
+ assertEquals 'Groupe motif 2', editedGroupeMotif.libelle
+
+ }
+
+ void testDeplacerMonter() {
+
+ def groupeMotif = new GroupeMotif(
+ preferencesEtablissement: preferencesEtablissement,
+ libelle: 'Groupe motif 10',
+ ordre: 1000
+ )
+
+ assertNotNull groupeMotif.save()
+
+
+
+ }
+
+ void testSaveThenDelete() {
+
+ def groupeMotif = new GroupeMotif(
+ preferencesEtablissement: preferencesEtablissement,
+ libelle: 'Groupe motif 1',
+ ordre: 0
+ )
+
+ assertNotNull groupeMotif.save()
+
+ def foundGroupeMotif = GroupeMotif.get(groupeMotif.id)
+ foundGroupeMotif.delete()
+
+ assertFalse GroupeMotif.exists(foundGroupeMotif.id)
+
+ }
+
+
+}
urlSupprimerGrpMotif:undefined,
urlModifierDispoMotif: undefined,
urlMonterGrpMotif: undefined,
- urlDescendreGrpMotif: undefined
+ urlDescendreGrpMotif: undefined,
+ urlDeplacerGrpMotif: undefined
},
libelle:{
grpMotifMonterSucces: undefined,
grpMotifMonterEchec: undefined,
grpMotifDescendreSucces: undefined,
- grpMotifDescendreEchec: undefined
+ grpMotifDescendreEchec: undefined,
+ grpMotifDeplacerSucces: undefined,
+ grpMotifDeplacerEchec: undefined
},
data:{
supprime: this.supprime.createDelegate(this),
monte: this.monte.createDelegate(this),
descend: this.descend.createDelegate(this),
+ deplace: this.deplace.createDelegate(this),
modifieDispoMotif: this.modifieDispoMotif.createDelegate(this),
isGroupe: this.isGroupe.createDelegate(this),
isMotif: this.isMotif.createDelegate(this)
scope:this
});
}
+ },
+
+ deplace: function(adeplacerId, aremplacerId) {
+ eliot.absences.Message.resetMessages();
+
+ eliot.helper.AjaxHelper.request({
+
+ url:this.ConfigServeur.url.urlDeplacerGrpMotif,
+
+ params:{
+ adeplacerId: adeplacerId,
+ aremplacerId: aremplacerId
+ },
+
+ success:function (reponse) {
+ if ((reponse.message !== undefined) && (reponse.message !== '')) {
+ eliot.absences.Message.showConfirmation(reponse.message);
+ }
+ else {
+ eliot.absences.Message.showConfirmation(this.ConfigServeur.message.grpMotifDeplacerSucces);
+ }
+ this.view.updateOrdre(reponse.data);
+ },
+
+ failure:function (reponse) {
+ if ((reponse.message !== undefined) && (reponse.message !== '')) {
+ eliot.absences.Message.showErreur(reponse.message);
+ }
+ else {
+ eliot.absences.Message.showErreur(this.ConfigServeur.message.grpMotifDeplacerEchec);
+ }
+ },
+
+ scope:this
+ });
}
});
\ No newline at end of file
descend: this.descend.createDelegate(this),
openPopup: this.openPopup.createDelegate(this),
creeNode: this.creeNode.createDelegate(this),
- modifieNode: this.modifieNode.createDelegate(this)
+ modifieNode: this.modifieNode.createDelegate(this),
+ updateOrdre: this.updateOrdre.createDelegate(this)
}
},
this.gridPlugins = [];
this.parametrageMotifGrid = new Ext.ux.tree.ColumnTree({
+ enableDD: true,
autoScroll: true,
autoWidth:false,
rootVisible: false,
}
}),
listeners: {
+
afterrender: function() {
this.parametrageMotifGrid.expandAll();
this.checkColumnsAfterRender();
},
+
click: function(node) {
this.config.model.setValue(node);
},
+
+ nodedragover: function (event) {
+ return this.nodedragover(event);
+ },
+
+ movenode: function (tree, node, oldParent, newParent, position) {
+ this.movenode(tree, node, oldParent, newParent, position);
+ },
+
scope: this
}
});
this.config.model.setValue.defer(1, this.config.model, [node]);
},
+ updateOrdre: function(nodes) {
+ for(var i = 0; i < nodes.length; i++) {
+ var node = nodes[i];
+ var treeNode = this.rootNode.findChild('id', node.id);
+ if (treeNode != null) {
+ treeNode.attributes.ordre = node.ordre;
+ }
+ }
+
+ // Pour déclencher le tri
+ var treeNode = this.rootNode.childNodes[0];
+ treeNode.setText(treeNode.text);
+ },
+
openPopup: function(config) {
var couleurSel = config.couleurSel;
else if (this.config.controller.isGroupe(node)) {
node.setText(encodedLibelle);
}
+ },
+
+ nodedragover: function (event) {
+ if ((event.point == 'append') &&(event.target != this.rootNode)) {
+ return false;
+ }
+
+ if (event.target.parentNode != this.rootNode) {
+ return false;
+ }
+
+ return true;
+ },
+
+ movenode: function (tree, node, oldParent, newParent, position) {
+ this.movenodeAfterOrder.defer(1, this, [node, newParent, position]);
+ },
+
+ movenodeAfterOrder: function(node, parent, position) {
+ target = parent.childNodes[position];
+ this.config.controller.deplace(node.id, target.id)
}
});
\ No newline at end of file