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 20711f249850e1874d020dc07142b243e75dcfff Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Oct 24 10:54:21 2017 +0200 Ajouter le créateur automatiquement dans les participant d'un sondage restreint (ref #155) --- pollen-ui-riot-js/src/main/web/js/PollForm.js | 3 +++ pollen-ui-riot-js/src/main/web/js/VoterListService.js | 12 ++++++++++++ .../src/main/web/tag/voterList/VoterList.tag.html | 10 +++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/pollen-ui-riot-js/src/main/web/js/PollForm.js b/pollen-ui-riot-js/src/main/web/js/PollForm.js index 7fa51e1e..a3a0c15e 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -254,6 +254,9 @@ class PollForm { this.pageTracker.trackCreatePoll(this.step); this.maxStepReached = this.step; } + if (this.creation && this.step === 3) { + voterListService.addMeIfEmpty(); + } } setSettingsDefault() { diff --git a/pollen-ui-riot-js/src/main/web/js/VoterListService.js b/pollen-ui-riot-js/src/main/web/js/VoterListService.js index b36895a1..f233fbac 100644 --- a/pollen-ui-riot-js/src/main/web/js/VoterListService.js +++ b/pollen-ui-riot-js/src/main/web/js/VoterListService.js @@ -93,6 +93,18 @@ class VoterListService extends FetchService { return mainVoterListPromise; } + addMeIfEmpty() { + let mainList = this.pollForm.mainVoterList; + let name = this.pollForm.model.creatorName; + let email = this.pollForm.model.creatorEmail; + if (mainList.countMembers === 0 && mainList.countSubLists === 0 && email) { + let me = this._newMember(mainList, name, email, 1); + mainList.members.push(me); + this.voterListMembersById[me.id] = me; + mainList.countMembers = mainList.members.length; + } + } + loadList(voterList) { let voterListPromise; if (!voterList.loadded) { diff --git a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html index 4d5f5754..b24ef752 100644 --- a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterList.tag.html @@ -60,7 +60,7 @@ require("../components/ContextualMenu.tag.html"); <ContextualMenu if={!opts.form.model.closed} icon="fa-ellipsis-v" - open-force={opts.form.currentVoterList.countMembers === 0 && opts.form.currentVoterList.countSubLists === 0}> + open-force={emptyListOrOnlyMe()}> <a onclick={parent.addMember} > <i class="fa fa-plus" aria-hidden="true"></i> <i class="fa fa-user" aria-hidden="true"></i> @@ -199,6 +199,14 @@ require("../components/ContextualMenu.tag.html"); && voterListService.countAllEmails(this.opts.form.mainVoterList) > this.opts.form.model.maxVoters; }; + this.emptyListOrOnlyMe = () => { + return this.opts.form.currentVoterList.countSubLists === 0 + && (this.opts.form.currentVoterList.countMembers === 0 + || (this.opts.form.currentVoterList.countMembers === 1 + && this.opts.form.currentVoterList.members[0].name === this.opts.form.model.creatorName + && this.opts.form.currentVoterList.members[0].email === this.opts.form.model.creatorEmail)); + }; + this.submit = () => { this.opts.form.mainVoterList.name = this.__.mainList + this.opts.form.model.title; }; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.