mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
poll routing hints in the app, demo precision in header
This commit is contained in:
parent
b06a44fb98
commit
8322a9a83a
@ -6,7 +6,7 @@
|
||||
>
|
||||
<h1 >
|
||||
<span class="logo_first" >Frama</span >
|
||||
<span class="logo_second" >date</span >
|
||||
<span class="logo_second" >date</span > (démo)
|
||||
</h1 >
|
||||
<div class="legend" >proposé par
|
||||
<span class="legend_first" >Frama</span >
|
||||
|
@ -46,8 +46,8 @@ export class PollConfig {
|
||||
password = '';
|
||||
customUrl = ''; // custom slug in the url, must be unique
|
||||
customUrlIsUnique = null; // given by the backend
|
||||
urlPublic = environment.baseApiHref + '/default-url';
|
||||
urlAdmin = environment.baseApiHref + '/default-url/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
|
||||
urlPublic = environment.baseHref + '/#/poll/id/3';
|
||||
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
|
||||
canModifyAnswers = 1;// everybody, self, nobody (= just admin)
|
||||
whoModifiesAnswers = "self";// everybody, self, nobody (= just admin)
|
||||
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)
|
||||
|
@ -36,6 +36,7 @@ export const Routes =
|
||||
{path: 'step/end', component: EndConfirmationComponent},
|
||||
{path: 'graphic/:poll', component: PollGraphicComponent},
|
||||
{path: 'vote/poll/id/:poll', component: PollDisplayComponent},
|
||||
{path: 'vote/poll/slug/:pollSlug', component: PollDisplayComponent},
|
||||
{path: 'votechoice', component: VoteChoiceComponent},
|
||||
{path: 'voting', component: VotingComponent},
|
||||
{path: 'step/password', component: PasswordComponent},
|
||||
|
@ -19,16 +19,30 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.config.currentPoll;
|
||||
this.config.currentPoll;
|
||||
|
||||
// fetch poll with its ID or slug.
|
||||
const id = this.activeRoute.snapshot.params.poll;
|
||||
const pollSlug = this.activeRoute.snapshot.params.pollSlug;
|
||||
if (id) {
|
||||
this.config.pollId = id;
|
||||
|
||||
// store it in the poll property here
|
||||
this.config.getPollById(id).subscribe(
|
||||
(res: any) => {
|
||||
this.config.pollId = id;
|
||||
this.config.currentPoll = res;
|
||||
this.config.loading = false;
|
||||
}, (e) => {
|
||||
// handle need for a password
|
||||
this.config.handleError(e)
|
||||
}
|
||||
);
|
||||
} else if (pollSlug) {
|
||||
this.config.getPollByURL(pollSlug).subscribe(
|
||||
(res: any) => {
|
||||
this.config.pollId = res.id;
|
||||
this.config.currentPoll = res;
|
||||
this.config.loading = false;
|
||||
}, (e) => {
|
||||
// handle need for a password
|
||||
this.config.handleError(e)
|
||||
|
@ -114,7 +114,7 @@
|
||||
{{"visibility.access_instructions"|translate}}
|
||||
</sub >
|
||||
<div class="preview-url" >
|
||||
{{baseUrl + '/' + config.customUrl}}
|
||||
{{environment.baseHref + '#/poll/slug/' + config.customUrl}}
|
||||
</div >
|
||||
<br >
|
||||
<label for="passwordAccess" >
|
||||
|
@ -11,6 +11,7 @@ import {environment} from "../../../environments/environment";
|
||||
export class VisibilityComponent extends BaseComponent implements OnInit {
|
||||
showCustomPassword = false;
|
||||
baseUrl = environment.baseApiHref;
|
||||
environment = environment;
|
||||
|
||||
constructor(public config: ConfigService) {
|
||||
super(config);
|
||||
|
@ -28,6 +28,7 @@ export class ConfigService extends PollConfig {
|
||||
super();
|
||||
// fill in mock values if we are not in production environment
|
||||
if (!environment.production) {
|
||||
console.info(' ######### framadate ######### we are not in production env, filling with mock values');
|
||||
this.currentPoll = mockPoll3;
|
||||
this.myPolls = mockMyPolls;
|
||||
this.dateList = defaultDates;
|
||||
@ -44,6 +45,7 @@ export class ConfigService extends PollConfig {
|
||||
this.messageService.clear();
|
||||
}
|
||||
|
||||
// utils functions
|
||||
/**
|
||||
* generate unique id to have a default url for future poll
|
||||
*/
|
||||
@ -54,6 +56,10 @@ export class ConfigService extends PollConfig {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* make a uniq slug for the current poll creation
|
||||
* @param str
|
||||
*/
|
||||
makeSlug(str?: string) {
|
||||
if (!str) {
|
||||
str = this.creationDate.getFullYear() + '_' + (this.creationDate.getMonth() + 1) + '_' + this.creationDate.getDate() + '_' + this.myName + '_' + this.title;
|
||||
@ -96,29 +102,25 @@ export class ConfigService extends PollConfig {
|
||||
*/
|
||||
getPollConfig() {
|
||||
const jsonConfig = {
|
||||
method: 'POST',
|
||||
data: {
|
||||
|
||||
owner: {
|
||||
email: this.myEmail,
|
||||
pseudo: this.myName,
|
||||
},
|
||||
title: this.title,
|
||||
description: this.description,
|
||||
type: this.pollType,
|
||||
visibility: this.visibility,
|
||||
voteChoices: this.voteChoices,
|
||||
allowSeveralHours: this.allowSeveralHours,
|
||||
expirationDate: this.expirationDate,
|
||||
passwordAccess: this.passwordAccess,
|
||||
password: this.password,
|
||||
customUrl: this.customUrl,
|
||||
canModifyAnswers: this.canModifyAnswers,
|
||||
whoModifiesAnswers: this.whoModifiesAnswers,
|
||||
dateList: this.dateList,
|
||||
timeList: this.timeList,
|
||||
answers: this.answers,
|
||||
}
|
||||
owner: {
|
||||
email: this.myEmail,
|
||||
pseudo: this.myName,
|
||||
},
|
||||
title: this.title,
|
||||
description: this.description,
|
||||
type: this.pollType,
|
||||
visibility: this.visibility,
|
||||
voteChoices: this.voteChoices,
|
||||
allowSeveralHours: this.allowSeveralHours,
|
||||
expirationDate: this.expirationDate,
|
||||
passwordAccess: this.passwordAccess,
|
||||
password: this.password,
|
||||
customUrl: this.customUrl,
|
||||
canModifyAnswers: this.canModifyAnswers,
|
||||
whoModifiesAnswers: this.whoModifiesAnswers,
|
||||
dateList: this.dateList,
|
||||
timeList: this.timeList,
|
||||
answers: this.answers,
|
||||
};
|
||||
return jsonConfig
|
||||
}
|
||||
@ -226,13 +228,7 @@ export class ConfigService extends PollConfig {
|
||||
getPollByURL(url: string) {
|
||||
|
||||
this.todo();
|
||||
// this.http.get(`${this.baseHref}/poll/${url}`, this.makeHeaders()).subscribe(
|
||||
// (res: any) => {
|
||||
// this.myPolls = res.data;
|
||||
// }, (e) => {
|
||||
// this.handleError(e)
|
||||
// }
|
||||
// );
|
||||
return this.http.get(`${this.baseHref}/poll/slug/${url}`, this.makeHeaders())
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user