branch develop updated (b5474b1 -> 7eb9f58)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from b5474b1 déplacement des traductions dans les tags new 7eb9f58 liste de favoris : ajout des sous-listes dans l'UI The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 7eb9f58649edd7c7602a3d3c68468cb1a6fdc1aa Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Apr 19 15:53:51 2017 +0200 liste de favoris : ajout des sous-listes dans l'UI Summary of changes: .../persistence/entity/FavoriteListTopiaDao.java | 14 +- .../rest/api/PollenRestApiApplicationListener.java | 2 + .../service/FavoriteListImportFromLdap.java | 2 +- .../services/service/FavoriteListService.java | 6 +- .../i18n/pollen-services_fr_FR.properties | 8 +- pollen-ui-riot-js/src/main/web/i18n.json | 26 +++- pollen-ui-riot-js/src/main/web/js/Error.js | 6 +- .../src/main/web/js/FavoriteListService.js | 20 +++ pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 2 +- .../src/main/web/tag/PollenErrorManager.tag.html | 26 ++-- ...{MemberCard.tag.html => ChildListCard.tag.html} | 73 +++++----- .../web/tag/favoriteList/FavoriteList.tag.html | 150 +++++++++++++++++++-- .../web/tag/favoriteList/FavoriteListCard.tag.html | 2 +- .../main/web/tag/favoriteList/MemberCard.tag.html | 2 +- 14 files changed, 259 insertions(+), 80 deletions(-) copy pollen-ui-riot-js/src/main/web/tag/favoriteList/{MemberCard.tag.html => ChildListCard.tag.html} (59%) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 7eb9f58649edd7c7602a3d3c68468cb1a6fdc1aa Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Apr 19 15:53:51 2017 +0200 liste de favoris : ajout des sous-listes dans l'UI --- .../persistence/entity/FavoriteListTopiaDao.java | 14 +- .../rest/api/PollenRestApiApplicationListener.java | 2 + .../service/FavoriteListImportFromLdap.java | 2 +- .../services/service/FavoriteListService.java | 6 +- .../i18n/pollen-services_fr_FR.properties | 8 +- pollen-ui-riot-js/src/main/web/i18n.json | 26 +++- pollen-ui-riot-js/src/main/web/js/Error.js | 6 +- .../src/main/web/js/FavoriteListService.js | 20 +++ pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 2 +- .../src/main/web/tag/PollenErrorManager.tag.html | 26 ++-- ...{MemberCard.tag.html => ChildListCard.tag.html} | 73 +++++----- .../web/tag/favoriteList/FavoriteList.tag.html | 150 +++++++++++++++++++-- .../web/tag/favoriteList/FavoriteListCard.tag.html | 2 +- .../main/web/tag/favoriteList/MemberCard.tag.html | 2 +- 14 files changed, 259 insertions(+), 80 deletions(-) diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/FavoriteListTopiaDao.java b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/FavoriteListTopiaDao.java index e2d48df..a80ad5f 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/FavoriteListTopiaDao.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/FavoriteListTopiaDao.java @@ -30,10 +30,18 @@ public class FavoriteListTopiaDao extends AbstractFavoriteListTopiaDao<FavoriteL // --- Delete members --- // - FavoriteListMemberTopiaDao dao = topiaDaoSupplier + FavoriteListMemberTopiaDao memberDao = topiaDaoSupplier .getDao(FavoriteListMember.class, FavoriteListMemberTopiaDao.class); - List<FavoriteListMember> list = dao.forFavoriteListEquals(entity).findAll(); - dao.deleteAll(list); + List<FavoriteListMember> members = memberDao.forFavoriteListEquals(entity).findAll(); + memberDao.deleteAll(members); + + ChildFavoriteListTopiaDao childDao = topiaDaoSupplier + .getDao(ChildFavoriteList.class, ChildFavoriteListTopiaDao.class); + List<ChildFavoriteList> children = childDao.forChildEquals(entity).findAll(); + childDao.deleteAll(children); + + List<ChildFavoriteList> parents = childDao.forParentEquals(entity).findAll(); + childDao.deleteAll(parents); super.delete(entity); diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java index 859de99..b42f467 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java @@ -31,6 +31,7 @@ import org.chorem.pollen.rest.api.injector.PollenBeanIdInjector; import org.chorem.pollen.rest.api.injector.PollenRestApiRequestContextInjector; import org.chorem.pollen.rest.api.injector.PollenServiceInjector; import org.chorem.pollen.services.PollenUIContext; +import org.chorem.pollen.services.bean.ChildFavoriteListBean; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.CommentBean; import org.chorem.pollen.services.bean.FavoriteListBean; @@ -68,6 +69,7 @@ public class PollenRestApiApplicationListener implements WebMotionServerListener PollenUserBean.class, FavoriteListBean.class, FavoriteListMemberBean.class, + ChildFavoriteListBean.class, VoterListBean.class, VoterListMemberBean.class, PaginationParameterBean.class, diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListImportFromLdap.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListImportFromLdap.java index c2434ec..bb8d446 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListImportFromLdap.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListImportFromLdap.java @@ -120,7 +120,7 @@ public class FavoriteListImportFromLdap extends PollenServiceSupport implements Attribute attrName = r.getAttributes().get("cn"); Attribute attrEmail = r.getAttributes().get("mail"); - if (attrName != null) { + if (attrName != null && attrEmail != null) { String memberName = attrName.get().toString().trim(); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java index 8ac2b24..159b1aa 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/FavoriteListService.java @@ -506,12 +506,14 @@ public class FavoriteListService extends PollenServiceSupport { l(getLocale(), "pollen.error.childFavoriteList.already.used")); } + + boolean sameList = parentList.getTopiaId().equals(childFavoriteList.getChild().getEntityId()); check(errors, ChildFavoriteList.PROPERTY_CHILD, - !parentList.getTopiaId().equals(childFavoriteList.getChild().getEntityId()), + !sameList, l(getLocale(), "pollen.error.childFavoriteList.sameParentChild", parentList.getName())); check(errors, ChildFavoriteList.PROPERTY_CHILD, - !getChildFavoriteListDao().isAncestorOrSelf(childFavoriteList.getChild().getEntityId(), parentList.getTopiaId()), + sameList || !getChildFavoriteListDao().isAncestorOrSelf(childFavoriteList.getChild().getEntityId(), parentList.getTopiaId()), l(getLocale(), "pollen.error.childFavoriteList.childIsAncestor", parentList.getName(), childFavoriteList.getChild().getName())); check(errors, "weight", childFavoriteList.getWeight() > 0, l(getLocale(), "pollen.error.childFavoriteList.weight.negativeOrNull")); diff --git a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties index ae604bd..318f403 100644 --- a/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties +++ b/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties @@ -29,10 +29,10 @@ pollen.configuration.uiUrlPollVote=Url de vote sur un sondage pollen.configuration.version=Version de l'application pollen.configurqtion.uiUrlPollVoteEdit=Url d'édition de vote sur un sondage pollen.configurqtion.uiUrlUserValidate=Url de validation d'un compte utilisateur -pollen.error.childFavoriteList.already.used=La sous-liste est déjaà utlisée -pollen.error.childFavoriteList.childIsAncestor=La liste principal %s est déjà une sous-liste de %s -pollen.error.childFavoriteList.sameParentChild=La sous-lists ne peut pas être la liste principal -pollen.error.childFavoriteList.weight.negativeOrNull=le poids de la sous-liste doit être positif +pollen.error.childFavoriteList.already.used=La sous-liste est déja utlisée +pollen.error.childFavoriteList.childIsAncestor=La sous-liste "%2s" ne doit pas dépendre de la liste principal "%1s" +pollen.error.childFavoriteList.sameParentChild=La liste principal ne peut avoir comme sous-lists elle-même +pollen.error.childFavoriteList.weight.negativeOrNull=le poids de la sous-liste doit être positif pollen.error.choice.choiceDateEmpty=La date ne peut pas être vide pollen.error.choice.choiceDateExist=La date exist déjà utilisé sur ce sondage pollen.error.choice.choiceDateInvalid=Le format de la date %s n'est pas valide diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index 2d4118f..59ce4cc 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -332,7 +332,7 @@ "favoriteList_deleteMessage": "Supprimer la liste de votants ?", "favoriteList_noMember": "Aucun membre dans cette liste", "favoriteList_members": "Membres de la liste", - "favoriteList_member_new": "Nouveau Membre", + "favoriteList_member_new": "Nouveau membre", "favoriteList_member_import": "Importer", "favoriteList_member_importCsv": "Importer des membres à partir d'un fichier", "favoriteList_member_csvFile": "Fichier des membres", @@ -356,6 +356,18 @@ "favoriteList_member_weight": "Poids", "favoriteList_member_ldap_placeholder": "L'adresse de l'annuaire LDAP", "favoriteList_member_add": "Ajouter", + "favoriteList_childrenLists": "Sous-listes", + "favoriteList_weight": "Poids", + "favoriteList_noChildList": "Aucune sous-listes", + "favoriteList_childList_new": "Nouvelle sous-liste", + "favoriteList_childList": "Sous-liste", + "favoriteList_childList_child": "Sous-liste", + "favoriteList_childList_weight": "Poids", + "favoriteList_childList_cancel": "Annuler", + "favoriteList_childList_save": "Enregistrer", + "favoriteList_childList_add": "Ajouter", + "favoriteList_childList_delete": "Retirer la sous-liste", + "favoriteList_childList_deleteMessage": "Retirer la sou-liste ?", "error_manager_403": "Erreur : Accès refusé", "error_manager_500": "Erreur : Service indisponible" }, @@ -706,6 +718,18 @@ "favoriteList_member_weight": "Weight", "favoriteList_member_ldap_placeholder": "LDAP repository address", "favoriteList_member_add": "Add", + "favoriteList_childrenLists": "Sub-lists", + "favoriteList_weight": "Weight", + "favoriteList_noChildList": "No sub-lists", + "favoriteList_childList_new": "New sud-list", + "favoriteList_childList": "Sub-list", + "favoriteList_childList_child": "Sub-list", + "favoriteList_childList_weight": "Weight", + "favoriteList_childList_cancel": "Cancel", + "favoriteList_childList_save": "Save", + "favoriteList_childList_add": "Ajouter", + "favoriteList_childList_delete": "Remove sub-list", + "favoriteList_childList_deleteMessage": "Remove sub-list ?", "error_manager_403": "Error: Forbidden access", "error_manager_500": "Error: Service unavailable" } diff --git a/pollen-ui-riot-js/src/main/web/js/Error.js b/pollen-ui-riot-js/src/main/web/js/Error.js index bbe7513..775a6c2 100644 --- a/pollen-ui-riot-js/src/main/web/js/Error.js +++ b/pollen-ui-riot-js/src/main/web/js/Error.js @@ -24,8 +24,11 @@ class Error { if (e instanceof Error) { this.message = e.message; this.timeout = e.timeout; - } else { + } else if (e instanceof String) { this.message = e; + } else { + this.message = Object.values(e) + .reduce((messages, messagesfield) => messages.concat(messagesfield), []); } if (!this.timeout) { this.timeout = timeout; @@ -34,4 +37,3 @@ class Error { } module.exports = Error; - diff --git a/pollen-ui-riot-js/src/main/web/js/FavoriteListService.js b/pollen-ui-riot-js/src/main/web/js/FavoriteListService.js index 0a46a25..04877ec 100644 --- a/pollen-ui-riot-js/src/main/web/js/FavoriteListService.js +++ b/pollen-ui-riot-js/src/main/web/js/FavoriteListService.js @@ -71,6 +71,26 @@ class FavoriteListService extends FetchService { return this.doDelete("/v1/favoriteLists/" + favoriteListId + "/members/" + memberId); } + childrenLists(favoriteListId, pagination) { + return this.getWithParams("/v1/favoriteLists/" + favoriteListId + "/lists", {paginationParameter: pagination}); + } + + childList(favoriteListId, childListId) { + return this.get("/v1/favoriteLists/" + favoriteListId + "/lists/" + childListId); + } + + addChildList(favoriteListId, childList) { + return this.form("/v1/favoriteLists/" + favoriteListId + "/lists", {childList: childList}); + } + + saveChildList(favoriteListId, childList) { + return this.form("/v1/favoriteLists/" + favoriteListId + "/lists/" + childList.id, {childList: childList}); + } + + deleteChildList(favoriteListId, childListId) { + return this.doDelete("/v1/favoriteLists/" + favoriteListId + "/lists/" + childListId); + } + } module.exports = singleton(FavoriteListService); diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html index 404d33e..4c2fa0f 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html @@ -221,7 +221,7 @@ require("./favoriteList/FavoriteList.tag.html"); } pollenerrormanager { - position: absolute; + position: fixed; bottom: 20px; right: 0px; } diff --git a/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html b/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html index d5b0d48..288854c 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html @@ -2,12 +2,14 @@ <div each={error in errors} class="pollen-error" id="{error.id}"> <div class="close-error" onclick="{closeError(error.id)}"><i class="fa fa-times" aria-hidden="true"></i></div> - {error.message} + <span if={!Array.isArray(error.message)}> {error.message}</span> + <ul if={Array.isArray(error.message)}> + <li each={message in error.message}>{message}</li> + </ul> </div> - <style> <script type="es6"> - let Error = require('../js/Error'); + let Error = require("../js/Error"); let session = require("../js/Session"); this.installBundle(session, "error_manager"); @@ -17,7 +19,7 @@ this.handleErrors = (e) => { var error = new Error(e); if (!error.timeout) { - error.timeout = session.configuration.defaultErrorTimeout + error.timeout = session.configuration.defaultErrorTimeout; } error.id = "error-" + this.errorIndex++; @@ -42,15 +44,19 @@ e.preventDefault(); e.stopPropagation(); } - console.log(errorId); + var errorElement = document.getElementById(errorId); - errorElement.addEventListener("transitionend", () => { - errorElement.parentNode.removeChild(errorElement); - }); - errorElement.style.transform = "scaleY(0)"; + if (errorElement) { + errorElement.addEventListener("transitionend", () => { + errorElement.parentNode.removeChild(errorElement); + }); + errorElement.style.transform = "scaleY(0)"; + } }; </script> + + <style> .pollen-error { width: 300px; background: #ffcccc; @@ -72,4 +78,4 @@ } </style> -</PollenErrorManager> \ No newline at end of file +</PollenErrorManager> diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/MemberCard.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/ChildListCard.tag.html similarity index 59% copy from pollen-ui-riot-js/src/main/web/tag/favoriteList/MemberCard.tag.html copy to pollen-ui-riot-js/src/main/web/tag/favoriteList/ChildListCard.tag.html index edb01f0..bff81db 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/MemberCard.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/ChildListCard.tag.html @@ -1,12 +1,12 @@ -<MemberCard> +<ChildListCard> - <div class="member-card-view" if={!editing}> + <div class="child-list-card-view" if={!editing}> <div class="info"> - <i class="fa fa-user" aria-hidden="true"></i> - <span if={opts.member.name !== opts.member.email}> - {opts.member.name} - - </span> - {opts.member.email} - {opts.member.weight} + <a href="#favoriteLists/{opts.childList.child.id}"> + <i class="fa fa-users" aria-hidden="true"></i> + {opts.childList.child.name} + </a> + - {opts.childList.weight} </div> <div class="member-actions u-xsmall"> @@ -24,34 +24,25 @@ </div> - <form class="member-card-edit" if={editing} onsubmit={save}> + <form class="childList-card-edit" if={editing} onsubmit={save}> <div class="o-form-element"> - <label class="c-label" for="name">{__.name}</label> + <label class="c-label" for="child">{__.child}</label> <input type="text" - id="name" - ref="name" + id="child" + ref="child" class="c-field" - value={opts.member.name}> + value={opts.childList.child.name} + disabled> </div> <div class="o-form-element"> - <label class="c-label" for="name">{__.email}</label> - <input type="email" - id="email" - ref="email" - required - class="c-field {c-field--error: errors.email}" - value={opts.member.email}> - <div class="c-hint c-hint--static c-hint--error" each={error in errors.email}>{error}</div> - </div> - <div class="o-form-element"> - <label class="c-label" for="email">{__.weight}</label> + <label class="c-label" for="weight">{__.weight}</label> <input type="number" id="weight" ref="weight" required - value={opts.member.weight} + value={opts.childList.weight} step="0.01" - class="c-field {c-field--error : errors.email}"> + class="c-field {c-field--error : errors.weight}"> </div> <div class="actions"> <button type="button" @@ -70,7 +61,7 @@ <script type="es6"> let session = require("../../js/Session"); - this.installBundle(session, "favoriteList_member"); + this.installBundle(session, "favoriteList_childList"); let favoriteListService = require("../../js/FavoriteListService"); this.editing = false; this.errors = {}; @@ -85,9 +76,9 @@ this.delete = () => { if (confirm(this.__.deleteMessage)) { - favoriteListService.deleteMember(this.opts.favoriteList.id, this.opts.member.id).then(() => { - if (this.opts.onMemberChange) { - this.opts.onMemberChange(); + favoriteListService.deleteChildList(this.opts.favoriteList.id, this.opts.childList.id).then(() => { + if (this.opts.onChildListChange) { + this.opts.onChildListChange(); } }); } @@ -96,11 +87,9 @@ this.save = e => { e.preventDefault(); e.stopPropagation(); - this.opts.member.name = this.refs.name.value; - this.opts.member.email = this.refs.email.value; - this.opts.member.weight = this.refs.weight.value; + this.opts.childList.weight = this.refs.weight.value; - favoriteListService.saveMember(this.opts.favoriteList.id, this.opts.member).then(() => { + favoriteListService.saveChildList(this.opts.favoriteList.id, this.opts.childList).then(() => { this.errors = {}; this.cancelEdition(); this.update(); @@ -114,7 +103,7 @@ <style> - membercard { + childlistcard { display: block; margin: 5px auto; border-radius: 4px; @@ -124,21 +113,21 @@ color: #13a2ff; } - .member-card-view { + .child-list-card-view { display: flex; justify-content: space-between; } - .member-actions { + .child-list-actions { display: flex; align-items: flex-start; } - .member-actions button { + .child-list-actions button { margin-left: 3px; } - .member-card-edit .o-form-element .c-label:first-child { + .child-list-card-edit .o-form-element .c-label:first-child { width: 25%; display: inline-block; text-align: right; @@ -147,16 +136,16 @@ padding-right: 5px; } - .member-card-edit .o-form-element .c-field { + .child-list-card-edit .o-form-element .c-field { width: 75%; display: inline-block; } - .member-card-edit .o-form-element .c-toggle, - .member-card-edit .o-form-element .c-hint { + .child-list-card-edit .o-form-element .c-toggle, + .child-list-card-edit .o-form-element .c-hint { margin-left: 25%; } </style> -</MemberCard> +</ChildListCard> diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html index d187791..3b778b3 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html @@ -1,5 +1,6 @@ require("../Pagination.tag.html"); require("./MemberCard.tag.html"); +require("./ChildListCard.tag.html"); <FavoriteList> <div class="container" > <div show="{loaded}"> @@ -75,6 +76,36 @@ require("./MemberCard.tag.html"); {__.noMember} </div> <hr/> + <h3 class="c-heading">{__.childrenLists}</h3> + <div show={childrenLists.length > 0} > + <div class="o-form-element sort"> + <label class="c-label" for="sort">{__.sort}</label> + <div class="c-input-group"> + <div class="o-field"> + <select class="c-field" + onchange={selectSortChildrenLists}> + <option value="topiaCreateDate">{__.createDate}</option> + <option value="name">{__.name}</option> + <option value="weight">{__.weight}</option> + </select> + </div> + <button class="c-button c-button--brand" + onclick={toggleSortChildrenLists}> + <i class="fa {paginationChildrenLists.desc ? 'fa-sort-amount-desc' : 'fa-sort-amount-asc'}"></i> + </button> + </div> + </div> + + <Pagination pagination={paginationChildrenLists} onchange="{refresh}"/> + + <ChildListCard each={childList in childrenLists} child-list={childList} favorite-list={parent.favoriteList} on-child-list-change={parent.refresh}/> + + <Pagination pagination={paginationChildrenLists} onchange="{refresh}"/> + </div> + <div show={childrenLists.length === 0} class="c-alert c-alert--info"> + {__.noChildList} + </div> + <hr/> <form class="form-add" onsubmit={addMember}> <h3 class="c-heading">{__.member_new}</h3> <div class="o-form-element"> @@ -84,7 +115,7 @@ require("./MemberCard.tag.html"); ref="nameMember" placeholder={__.member_name_placeholder} required - class="c-field {c-field--error : errors.name}"> + class="c-field {c-field--error : addMemberErrors.name}"> </div> <div class="o-form-element"> <label class="c-label" for="email">{__.member_email}</label> @@ -93,7 +124,7 @@ require("./MemberCard.tag.html"); ref="email" required placeholder={__.member_email_placeholder} - class="c-field {c-field--error : errors.email}"> + class="c-field {c-field--error : addMemberErrors.email}"> </div> <div class="o-form-element"> <label class="c-label" for="email">{__.member_weight}</label> @@ -103,7 +134,7 @@ require("./MemberCard.tag.html"); required value="1.00" step="0.01" - class="c-field {c-field--error : errors.email}"> + class="c-field {c-field--error : addMemberErrors.weight}"> </div> <div class="actions"> <a class="c-button c-button--ghost-info" @@ -128,7 +159,7 @@ require("./MemberCard.tag.html"); id="csvFile" ref="csvFile" required - class="c-field"> + class="c-field {c-field--error : csvErrors.error}"> <div class="exemple"> {__.member_csvFile_exemple_label} <code class="c-code c-code--multiline">{__.member_csvFile_exemple}</code> @@ -159,7 +190,7 @@ require("./MemberCard.tag.html"); ref="ldapUrl" required placeholder={__.member_ldap_placeholder} - class="c-field"> + class="c-field {c-field--error : ldapErrors.error}"> <div class="exemple"> {__.member_ldap_exemple_label} <code class="c-code c-code--multiline">{__.member_ldap_exemple}</code> @@ -180,6 +211,44 @@ require("./MemberCard.tag.html"); </button> </div> </form> + <hr/> + <form class="form-add" onsubmit={addChildList}> + <h3 class="c-heading">{__.childList_new}</h3> + <div class="o-form-element"> + <label class="c-label" for="childList">{__.childList_child}</label> + <select type="text" + id="childList" + ref="childList" + placeholder={__.member_name_placeholder} + required + class="c-field {c-field--error : childListErrors.child}"> + <option each={list, index in favoriteLists} value={index}>{list.name}</option> + </select> + </div> + <div class="o-form-element"> + <label class="c-label" for="childListWeight">{__.childList_weight}</label> + <input type="number" + id="childListWeight" + ref="childListWeight" + required + value="1.00" + step="0.01" + class="c-field {c-field--error : childListErrors.weight}"> + </div> + <div class="actions"> + <a class="c-button c-button--ghost-info" + href="#/favoriteLists" + if={favoriteList.id}> + <i class="fa fa-chevron-left" aria-hidden="true"></i> + {__.back} + </a> + <button class="c-button c-button--success" + type="submit"> + <i class="fa fa-users" aria-hidden="true"></i> + {__.childList_add} + </button> + </div> + </form> </virtual> </div> </div> @@ -191,16 +260,28 @@ require("./MemberCard.tag.html"); let favoriteListService = require("../../js/FavoriteListService"); this.addType = "member"; this.errors = {}; + this.addMemberErrors = {}; + this.csvErrors = {}; + this.ldapErrors = {}; + this.childListErrors = {}; this.pagination = { order: "topiaCreateDate", desc: true, pageSize: 5, pageNumber: 0 }; + this.paginationChildrenLists = { + order: "topiaCreateDate", + desc: true, + pageSize: 5, + pageNumber: 0 + }; this.favoriteList = { id: this.opts.favoriteListId }; this.members = []; + this.childrenLists = []; + this.favoriteLists = []; this.delete = () => { if (this.favoriteList.id && confirm(this.__.deleteMessage)) { @@ -221,6 +302,7 @@ require("./MemberCard.tag.html"); this.refresh(); }, errors => { this.errors = errors; + this.bus.trigger("error", errors); this.update(); }); } else { @@ -228,6 +310,7 @@ require("./MemberCard.tag.html"); route("/favoriteLists/" + result.id); }, errors => { this.errors = errors; + this.bus.trigger("error", errors); this.update(); }); } @@ -242,11 +325,21 @@ require("./MemberCard.tag.html"); if (this.favoriteList.id) { Promise.all([ favoriteListService.favoriteList(this.favoriteList.id), - favoriteListService.members(this.favoriteList.id, this.pagination) + favoriteListService.members(this.favoriteList.id, this.pagination), + favoriteListService.childrenLists(this.favoriteList.id, this.paginationChildrenLists), + favoriteListService.favoriteLists({ + order: "name", + desc: false, + pageSize: -1, + pageNumber: 0 + }) ]).then((results) => { this.favoriteList = results[0]; this.members = results[1].elements; Object.assign(this.pagination, results[1].pagination); + this.childrenLists = results[2].elements; + Object.assign(this.paginationChildrenLists, results[2].pagination); + this.favoriteLists = results[3].elements; this.loaded = true; this.update(); return this.favoriteList; @@ -266,13 +359,14 @@ require("./MemberCard.tag.html"); }; favoriteListService.addMember(this.favoriteList.id, member).then(() => { - this.errors = {}; + this.addMemeberErrors = {}; this.refs.nameMember.value = ""; this.refs.email.value = ""; this.refs.weight.value = "1.00"; this.refresh(); }, errors => { - this.errors = errors; + this.addMemberErrors = errors; + this.bus.trigger("error", errors); this.update(); }); }; @@ -282,11 +376,12 @@ require("./MemberCard.tag.html"); e.stopPropagation(); let csvFile = this.refs.csvFile.files[0]; favoriteListService.importCsv(this.favoriteList.id, csvFile).then(() => { - this.errors = {}; + this.csvErrors = {}; this.refs.csvFile.value = ""; this.refresh(); }, errors => { - this.errors = errors; + this.csvErrors = errors; + this.bus.trigger("error", errors); this.update(); }); }; @@ -297,12 +392,33 @@ require("./MemberCard.tag.html"); let ldap = this.refs.ldapUrl.value; favoriteListService.importLdap(this.favoriteList.id, ldap).then(() => { - this.errors = {}; + this.ldapErrors = {}; this.refs.nameMember.value = ""; this.refs.email.value = ""; this.refresh(); }, errors => { - this.errors = errors; + this.ldapErrors = errors; + this.bus.trigger("error", errors); + this.update(); + }); + }; + + this.addChildList = (e) => { + e.preventDefault(); + e.stopPropagation(); + let childList = { + child: this.favoriteLists[this.refs.childList.value], + weight: this.refs.childListWeight.value + }; + + favoriteListService.addChildList(this.favoriteList.id, childList).then(() => { + this.childListErrors = {}; + this.refs.childList.value = ""; + this.refs.childListWeight.value = "1.00"; + this.refresh(); + }, errors => { + this.childListErrors = errors; + this.bus.trigger("error", errors); this.update(); }); }; @@ -317,6 +433,16 @@ require("./MemberCard.tag.html"); this.refresh(); }; + this.toggleSortChildrenLists = () => { + this.paginationChildrenLists.desc = !this.paginationChildrenLists.desc; + this.refresh(); + }; + + this.selectSortChildrenLists = (e) => { + this.paginationChildrenLists.order = e.target.value; + this.refresh(); + }; + this.refresh(); </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteListCard.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteListCard.tag.html index 6dc72d3..30f845c 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteListCard.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteListCard.tag.html @@ -3,7 +3,7 @@ require("./MemberCard.tag.html"); <FavoriteListCard> <div class="favoriteList-card-view"> <div class="name"> - <a href="#/favoriteLists/{opts.favoriteList.id}"> + <a href="#favoriteLists/{opts.favoriteList.id}"> {opts.favoriteList.name} </a> </div> diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/MemberCard.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/MemberCard.tag.html index edb01f0..a5aa5c2 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/MemberCard.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/MemberCard.tag.html @@ -51,7 +51,7 @@ required value={opts.member.weight} step="0.01" - class="c-field {c-field--error : errors.email}"> + class="c-field {c-field--error : errors.weight}"> </div> <div class="actions"> <button type="button" -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm