end visibilty fields link with poll config

This commit is contained in:
Baptiste Lemoine 2019-11-23 14:58:44 +01:00
parent d107978f2c
commit f4108ee61b
4 changed files with 103 additions and 18 deletions

View File

@ -56,8 +56,11 @@ export class PollConfig {
// access // access
visibility = 'link_only'; // visible to anyone with the link: visibility = 'link_only'; // visible to anyone with the link:
voteChoices = 'only_yes'; // possible answers to a vote choice: only "yes", "yes, maybe, no" voteChoices = 'only_yes'; // possible answers to a vote choice: only "yes", "yes, maybe, no"
expirationDate = ''; // expiracy date
passwordAccess = 0;
password = ''; password = '';
customUrl = ''; customUrl = '';
canModifyAnswers =1;// everybody, self, nobody (= just admin)
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin) whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)
dateList: DateOption[] = defaultDates; // sets of days as strings, config to set identical time for days in a special days poll dateList: DateOption[] = defaultDates; // sets of days as strings, config to set identical time for days in a special days poll
timeList: DateOption[] = timeOfDay; // ranges of time expressed as strings timeList: DateOption[] = timeOfDay; // ranges of time expressed as strings

View File

@ -31,9 +31,9 @@
<h2> <h2>
{{"visibility.votes"|translate}} {{"visibility.votes"|translate}}
</h2> </h2>
<span> <label for="votes">
{{"visibility.votes_possible"|translate}} {{"visibility.votes_possible"|translate}}
</span> </label>
<select <select
name="votes" name="votes"
id="votes" id="votes"
@ -51,26 +51,93 @@
</select> </select>
</section> </section>
<section class="expiracy"> <section class="expiracy">
<span> <label for="expirationDate">
{{"visibility.archiving"|translate}} {{"visibility.archiving"|translate}}
</span> </label>
{{"visibility.archiving_start"|translate}} <input type="date"
{{"visibility.archiving_can"|translate}} id="expirationDate"
{{"visibility.archiving_can_not"|translate}} [(ngModel)]="config.expirationDate">
{{"visibility.archiving_end"|translate}} <div class="modification">
<label for="modificationAbility">
{{"visibility.archiving_start"|translate}}
</label>
<select
name="modificationAbility"
id="modificationAbility"
[(ngModel)]="config.canModifyAnswers">
<option value="1">
{{"visibility.archiving_can"|translate}}
</option>
<option value="0">
{{"visibility.archiving_can_not"|translate}}
</option>
</select>
<label for="modificationScope">
{{"visibility.archiving_end"|translate}}
</label>
<select
name="modificationScope"
id="modificationScope"
[(ngModel)]="config.canModifyAnswers">
<option value="self">
{{"visibility.modfiy_their"|translate}}
</option>
<option value="everybody">
{{"visibility.modfiy_everyone"|translate}}
</option>
</select>
</div>
</section> </section>
<section class="access"> <section class="access">
<h1> <h2>
{{"visibility.access"|translate}} {{"visibility.access"|translate}}
</h1> </h2>
{{"visibility.access_want"|translate}} <label for="url">
{{"visibility.access_want_yes"|translate}} {{"visibility.access_url"|translate}}
{{"visibility.access_want_no"|translate}} <br>
{{"visibility.access_protect"|translate}} {{"visibility.access_url_key"|translate}}
</label>
<input type="text"
name="url"
id="url"
[(ngModel)]="config.customUrl">
<sub class="instructions">
{{"visibility.access_instructions"|translate}}
</sub>
{{"visibility.access_want"|translate}}
<select name="passwordAccess" id="passwordAccess" [(ngModel)]="config.passwordAccess">
<option value="0"> {{"visibility.access_want_no"|translate}}</option>
<option value="1"> {{"visibility.access_want_yes"|translate}}</option>
</select>
<label for="password">
{{"visibility.access_protect"|translate}}
</label>
<input type="password"
name="password"
id="password"
min="8"
*ngIf="!showCustomPassword"
[(ngModel)]="config.password">
<input type="password"
name="password_visible"
id="password_visible"
min="8"
*ngIf="showCustomPassword"
[(ngModel)]="config.password">
<button class="btn btn--default" (click)="showCustomPassword = !showCustomPassword">
{{"visibility.see_pass"|translate}}
</button>
</section> </section>
<a [routerLink]="'/step/end'" class="btn btn--primary" i18n="@@confirm">C'est parfait!</a> <a [routerLink]="'/step/end'"
class="btn btn--primary">
{{"visibility.validate_btn"|translate}}
</a>

View File

@ -8,12 +8,24 @@ import {ConfigService} from '../../config.service';
styleUrls: ['./visibility.component.scss'] styleUrls: ['./visibility.component.scss']
}) })
export class VisibilityComponent extends BaseComponent implements OnInit { export class VisibilityComponent extends BaseComponent implements OnInit {
showCustomPassword = false;
constructor(public config: ConfigService) { constructor(public config: ConfigService) {
super(config); super(config);
} }
ngOnInit() { ngOnInit() {
this.config.customUrl = this.makeUuid();
}
/**
* generate unique id to have a default url for future poll
*/
makeUuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
} }
} }

View File

@ -84,12 +84,15 @@
"modfiy_their": "leur vote", "modfiy_their": "leur vote",
"modfiy_everyone": "tous les votes", "modfiy_everyone": "tous les votes",
"access": "Accès au sondage", "access": "Accès au sondage",
"access_url": "Les votants pourront y accéder via cette adresse :",
"access_url_key": "URL",
"see_pass": "voir",
"access_instructions": "peut contenir des lettres, chiffres et des tirets",
"access_want": "Je", "access_want": "Je",
"access_want_yes": "souhaite", "access_want_yes": "souhaite",
"access_want_no": "n'ai pas besoin", "access_want_no": "n'ai pas besoin",
"access_protect": "quil soit protégé par un mot de passe.", "access_protect": "quil soit protégé par un mot de passe.",
"access_url": "Les votants pourront y accéder via cette adresse :", "validate_btn": "Créer ce sondage !"
"access_url_key": "URL"
}, },
"admin": { "admin": {
"deletion": "Tout supprimer", "deletion": "Tout supprimer",