mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
creation poll style, fill DTO for creation
This commit is contained in:
parent
765299e1c3
commit
585d3a215e
@ -6,7 +6,7 @@
|
|||||||
"polls": [
|
"polls": [
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"slug": "picnic",
|
"custom_url": "picnic",
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"isAboutDate": true,
|
"isAboutDate": true,
|
||||||
@ -24,7 +24,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"slug": "vacances",
|
"custom_url": "vacances",
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"isAboutDate": true,
|
"isAboutDate": true,
|
||||||
|
@ -54,7 +54,7 @@ export class PollConfig {
|
|||||||
currentPoll; // current poll selected with createPoll or getPoll of ConfigService
|
currentPoll; // current poll selected with createPoll or getPoll of ConfigService
|
||||||
passwordAccess = 0;
|
passwordAccess = 0;
|
||||||
password = '';
|
password = '';
|
||||||
customUrl = ''; // custom slug in the url, must be unique
|
customUrl = ''; // custom custom_url in the url, must be unique
|
||||||
customUrlIsUnique = null; // given by the backend
|
customUrlIsUnique = null; // given by the backend
|
||||||
urlSlugPublic = null;
|
urlSlugPublic = null;
|
||||||
urlPublic = environment.production ? '' : document.location.href + '/poll/id/4';
|
urlPublic = environment.production ? '' : document.location.href + '/poll/id/4';
|
||||||
|
@ -33,7 +33,7 @@ const routes: Routes = [
|
|||||||
{ path: 'step/end', component: EndConfirmationComponent },
|
{ path: 'step/end', component: EndConfirmationComponent },
|
||||||
{ path: 'graphic/:poll', component: PollGraphicComponent },
|
{ path: 'graphic/:poll', component: PollGraphicComponent },
|
||||||
{ path: 'vote/poll/id/:id', component: PollDisplayComponent },
|
{ path: 'vote/poll/id/:id', component: PollDisplayComponent },
|
||||||
{ path: 'vote/poll/slug/:slug', component: PollDisplayComponent },
|
{ path: 'vote/poll/custom_url/:custom_url', component: PollDisplayComponent },
|
||||||
{ path: 'votingchoice', component: VotingChoiceComponent },
|
{ path: 'votingchoice', component: VotingChoiceComponent },
|
||||||
{ path: 'voting', component: VotingComponent },
|
{ path: 'voting', component: VotingComponent },
|
||||||
];
|
];
|
||||||
|
@ -39,7 +39,7 @@ export class AdminComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch poll with its ID or slug.
|
// fetch poll with its ID or custom_url.
|
||||||
fetchPoll() {
|
fetchPoll() {
|
||||||
const token = this.tokenForAdministration;
|
const token = this.tokenForAdministration;
|
||||||
const headers = this.utils.makeHeaders({ token: token });
|
const headers = this.utils.makeHeaders({ token: token });
|
||||||
|
@ -28,7 +28,7 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {}
|
ngOnInit(): void {}
|
||||||
|
|
||||||
// fetch poll with its ID or slug.
|
// fetch poll with its ID or custom_url.
|
||||||
fetchPoll() {
|
fetchPoll() {
|
||||||
const id = this.activeRoute.snapshot.params.poll;
|
const id = this.activeRoute.snapshot.params.poll;
|
||||||
const pollSlug = this.activeRoute.snapshot.params.pollSlug;
|
const pollSlug = this.activeRoute.snapshot.params.pollSlug;
|
||||||
|
@ -102,8 +102,8 @@
|
|||||||
{{ 'visibility.access_instructions' | translate }}
|
{{ 'visibility.access_instructions' | translate }}
|
||||||
</sub>
|
</sub>
|
||||||
<div class="preview-url">
|
<div class="preview-url">
|
||||||
<a [href]="'/vote/poll/slug/' + config.customUrl">
|
<a [href]="'/vote/poll/custom_url/' + config.customUrl">
|
||||||
{{ '/vote/poll/slug/' + config.customUrl }}
|
{{ '/vote/poll/custom_url/' + config.customUrl }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
@ -21,7 +21,7 @@ export class VisibilityComponent extends BaseComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.config.customUrl = 'un slug';
|
this.config.customUrl = 'un custom_url';
|
||||||
this.config.expirationDate = this.config
|
this.config.expirationDate = this.config
|
||||||
.addDaysToDate(this.config.expiracyDateDefaultInDays, new Date())
|
.addDaysToDate(this.config.expiracyDateDefaultInDays, new Date())
|
||||||
.toISOString()
|
.toISOString()
|
||||||
|
@ -97,12 +97,12 @@ export class ConfigService extends PollConfig {
|
|||||||
// TODO: http requests moved to apiService
|
// TODO: http requests moved to apiService
|
||||||
this.customUrlIsUnique = null;
|
this.customUrlIsUnique = null;
|
||||||
if (!slug) {
|
if (!slug) {
|
||||||
slug = 'un slug';
|
slug = 'un custom_url';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
// TODO
|
// TODO
|
||||||
this.todo('check slug is unique');
|
this.todo('check custom_url is unique');
|
||||||
this.http
|
this.http
|
||||||
.get(`${this.apiBaseHref}/check-slug-is-uniq/${slug}`, this.utils.makeHeaders({ slug: this.customUrl }))
|
.get(`${this.apiBaseHref}/check-slug-is-uniq/${slug}`, this.utils.makeHeaders({ slug: this.customUrl }))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
@ -163,7 +163,7 @@ export class ConfigService extends PollConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get one poll by its slug choice_label
|
* get one poll by its custom_url choice_label
|
||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
getPollByURL(url: string) {
|
getPollByURL(url: string) {
|
||||||
@ -219,7 +219,7 @@ export class ConfigService extends PollConfig {
|
|||||||
this.pollId = res.poll.id;
|
this.pollId = res.poll.id;
|
||||||
this.owner_modifier_token = res.owner_modifier_token;
|
this.owner_modifier_token = res.owner_modifier_token;
|
||||||
this.urlPublic = this.apiBaseHref + '/vote/poll/id/' + res.poll.id;
|
this.urlPublic = this.apiBaseHref + '/vote/poll/id/' + res.poll.id;
|
||||||
this.urlSlugPublic = this.apiBaseHref + '/vote/poll/slug/' + res.poll.id;
|
this.urlSlugPublic = this.apiBaseHref + '/vote/poll/custom_url/' + res.poll.id;
|
||||||
if (res.poll.customUrl) {
|
if (res.poll.customUrl) {
|
||||||
this.urlSlugPublic = this.apiBaseHref + '/vote/poll/id/' + res.poll.customUrl;
|
this.urlSlugPublic = this.apiBaseHref + '/vote/poll/id/' + res.poll.customUrl;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { RouterModule } from '@angular/router';
|
|||||||
import { routes } from './routes-framadate';
|
import { routes } from './routes-framadate';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [RouterModule.forRoot(routes, { useHash: true })],
|
imports: [RouterModule.forRoot(routes)],
|
||||||
exports: [RouterModule],
|
exports: [RouterModule],
|
||||||
})
|
})
|
||||||
export class AppRoutingModule {}
|
export class AppRoutingModule {}
|
||||||
|
@ -10,14 +10,10 @@ export class Poll {
|
|||||||
|
|
||||||
public default_expiracy_days_from_now = 60;
|
public default_expiracy_days_from_now = 60;
|
||||||
|
|
||||||
public title = 'mon titre';
|
|
||||||
|
|
||||||
public kind: string;
|
public kind: string;
|
||||||
|
|
||||||
public description?: string;
|
public description?: string;
|
||||||
|
|
||||||
public custom_url?: string;
|
|
||||||
|
|
||||||
public expiracy_date?: string;
|
public expiracy_date?: string;
|
||||||
|
|
||||||
public creation_date?: string;
|
public creation_date?: string;
|
||||||
@ -49,40 +45,13 @@ export class Poll {
|
|||||||
public dateChoices: Choice[] = [];
|
public dateChoices: Choice[] = [];
|
||||||
// sets of days as strings, config to set identical time for days in a special days poll
|
// sets of days as strings, config to set identical time for days in a special days poll
|
||||||
public timeChoices: Choice[] = []; // ranges of time expressed as strings
|
public timeChoices: Choice[] = []; // ranges of time expressed as strings
|
||||||
constructor(public owner: Owner = new Owner(), public urlPublic: string = '', public slug: string = '') {}
|
constructor(public owner: Owner = new Owner(), public title = 'mon titre', public custom_url: string = '') {}
|
||||||
|
|
||||||
public static adaptFromLocalJsonServer(
|
|
||||||
item: Pick<Poll, 'owner' | 'title' | 'description' | 'slug' | 'configuration' | 'comments' | 'choices'>
|
|
||||||
): Poll {
|
|
||||||
return new Poll(
|
|
||||||
new Owner(item.owner.pseudo, item.owner.email, undefined),
|
|
||||||
''
|
|
||||||
// item.slug,
|
|
||||||
// item.title,
|
|
||||||
// item.description
|
|
||||||
// item.configuration,
|
|
||||||
// item.comments
|
|
||||||
// .map(
|
|
||||||
// (c: Pick<Comment, 'author' | 'content' | 'dateCreated'>) =>
|
|
||||||
// new Comment(c.author, c.content, new Date(c.dateCreated))
|
|
||||||
// )
|
|
||||||
// .sort(Comment.sortChronologically),
|
|
||||||
// item.choices.map((c: Pick<Choice, 'label' | 'url' | 'participants' | 'counts'>) => {
|
|
||||||
// const choice = new Choice(c.label, c.url, new Map(c.participants));
|
|
||||||
// choice.participants.forEach((value, key) => {
|
|
||||||
// choice.participants.set(key, new Set(value));
|
|
||||||
// });
|
|
||||||
// choice.updateCounts();
|
|
||||||
// return choice;
|
|
||||||
// })
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getAdministrationUrl(): string {
|
public getAdministrationUrl(): string {
|
||||||
return `${environment.api.baseHref}/administration/polls/${this.slug}`;
|
return `${environment.api.baseHref}/administration/polls/${this.custom_url}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getParticipationUrl(): string {
|
public getParticipationUrl(): string {
|
||||||
return `${environment.api.baseHref}/participation/polls/${this.slug}`;
|
return `${environment.api.baseHref}/participation/polls/${this.custom_url}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ export class ApiService {
|
|||||||
* @param poll
|
* @param poll
|
||||||
* @param vote_stack
|
* @param vote_stack
|
||||||
*/
|
*/
|
||||||
public sendVoteStackOfPoll(poll: Poll, vote_stack: Stack): Observable<any> {
|
public sendNewVoteStackOfPoll(poll: Poll, vote_stack: Stack): Observable<any> {
|
||||||
// api_new_vote_stack POST ANY ANY /api/v1/poll/{id}/answer
|
// api_new_vote_stack POST ANY ANY /api/v1/poll/{id}/answer
|
||||||
|
|
||||||
console.log('vote_stack', vote_stack);
|
console.log('vote_stack', vote_stack);
|
||||||
@ -181,7 +181,7 @@ export class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getPollBySlug(slug: string): Promise<Poll | undefined> {
|
public async getPollByCustomUrl(slug: string): Promise<Poll | undefined> {
|
||||||
try {
|
try {
|
||||||
// TODO: this interceptor should be avoided if backends returns the good object
|
// TODO: this interceptor should be avoided if backends returns the good object
|
||||||
const adapterInterceptor: number = this.axiosInstance.interceptors.response.use(
|
const adapterInterceptor: number = this.axiosInstance.interceptors.response.use(
|
||||||
@ -192,7 +192,7 @@ export class ApiService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const response: AxiosResponse<Poll> = await this.axiosInstance.get<Poll>(`${this.pollsEndpoint}/${slug}`);
|
const response: AxiosResponse<Poll> = await this.axiosInstance.get<Poll>(`${this.pollsEndpoint}/${slug}`);
|
||||||
console.log('fetch API : asking for poll with slug=' + slug, { response });
|
console.log('fetch API : asking for poll with custom_url=' + slug, { response });
|
||||||
|
|
||||||
axios.interceptors.request.eject(adapterInterceptor);
|
axios.interceptors.request.eject(adapterInterceptor);
|
||||||
|
|
||||||
@ -206,12 +206,12 @@ export class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getPollBySlugWithHash(slug: string, hash: string): Promise<Poll | undefined> {
|
public async getPollByCustomUrlWithHash(slug: string, hash: string): Promise<Poll | undefined> {
|
||||||
try {
|
try {
|
||||||
const response: AxiosResponse<Poll> = await this.axiosInstance.get<Poll>(
|
const response: AxiosResponse<Poll> = await this.axiosInstance.get<Poll>(
|
||||||
`${this.pollsEndpoint}/${slug}/pass/${hash}`
|
`${this.pollsEndpoint}/${slug}/pass/${hash}`
|
||||||
);
|
);
|
||||||
console.log('fetch API : asking for poll with slug=' + slug, { response });
|
console.log('fetch API : asking for poll with custom_url=' + slug, { response });
|
||||||
|
|
||||||
return response && response.data && !Array.isArray(response.data) ? response.data : undefined;
|
return response && response.data && !Array.isArray(response.data) ? response.data : undefined;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -225,7 +225,7 @@ export class ApiService {
|
|||||||
|
|
||||||
public async getSlug(slug: string): Promise<boolean> {
|
public async getSlug(slug: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
// TODO: scenario should be : if we can get this slug, it exists. if not, it doesn't. It's just a GET.
|
// TODO: scenario should be : if we can get this custom_url, it exists. if not, it doesn't. It's just a GET.
|
||||||
const response: AxiosResponse = await this.axiosInstance.get(
|
const response: AxiosResponse = await this.axiosInstance.get(
|
||||||
`${this.pollsEndpoint}${this.slugsEndpoint}/${slug}`
|
`${this.pollsEndpoint}${this.slugsEndpoint}/${slug}`
|
||||||
);
|
);
|
||||||
@ -244,12 +244,9 @@ export class ApiService {
|
|||||||
////////////
|
////////////
|
||||||
// UPDATE //
|
// UPDATE //
|
||||||
|
|
||||||
public async sendEmailToUserOfItsPollsList(email: string): Promise<void> {
|
public async sendUpdateVoteStack(vote_stack: Stack) {
|
||||||
// If user is not authenticated: the list of polls is send to user's email by the backend.
|
|
||||||
try {
|
try {
|
||||||
await this.axiosInstance.get<Poll[]>(
|
return await this.axiosInstance.patch(`${this.baseHref}/vote_stack/${vote_stack.id}`, vote_stack);
|
||||||
`${this.usersEndpoint}/${email}${this.usersPollsEndpoint}${this.usersPollsSendEmailEndpoint}`
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ApiService.handleError(error);
|
ApiService.handleError(error);
|
||||||
}
|
}
|
||||||
@ -295,9 +292,6 @@ export class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////
|
|
||||||
// PRIVATE METHODS //
|
|
||||||
|
|
||||||
public async deletePollAnswers(slug: string): Promise<boolean> {
|
public async deletePollAnswers(slug: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
const response: AxiosResponse = await this.axiosInstance.delete(
|
const response: AxiosResponse = await this.axiosInstance.delete(
|
||||||
@ -319,4 +313,18 @@ export class ApiService {
|
|||||||
ApiService.handleError(error);
|
ApiService.handleError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/////////////////////
|
||||||
|
// PRIVATE METHODS //
|
||||||
|
/////////////////////
|
||||||
|
|
||||||
|
public async sendEmailToUserOfItsPollsList(email: string): Promise<void> {
|
||||||
|
// If user is not authenticated: the list of polls is send to user's email by the backend.
|
||||||
|
try {
|
||||||
|
await this.axiosInstance.get<Poll[]>(
|
||||||
|
`${this.usersEndpoint}/${email}${this.usersPollsEndpoint}${this.usersPollsSendEmailEndpoint}`
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
ApiService.handleError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,15 +40,19 @@ export class PollService implements Resolve<Poll> {
|
|||||||
*/
|
*/
|
||||||
public async resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<Poll> {
|
public async resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<Poll> {
|
||||||
const segments: string[] = state.url.split('/');
|
const segments: string[] = state.url.split('/');
|
||||||
const wantedSlug: string = segments.includes('poll') ? segments[segments.indexOf('poll') + 1] : '';
|
const wantedcustom_url: string = segments.includes('poll') ? segments[segments.indexOf('poll') + 1] : '';
|
||||||
if (!wantedSlug && state.url.includes('administration')) {
|
if (!wantedcustom_url && state.url.includes('administration')) {
|
||||||
// creation of new poll
|
// creation of new poll
|
||||||
const poll = new Poll(this.userService.getCurrentUser(), this.uuidService.getUUID(), '');
|
const poll = new Poll(this.userService.getCurrentUser(), this.uuidService.getUUID(), '');
|
||||||
this._poll.next(poll);
|
this._poll.next(poll);
|
||||||
this.router.navigate(['poll/' + poll.slug + '/administration']);
|
this.router.navigate(['poll/' + poll.custom_url + '/administration']);
|
||||||
}
|
}
|
||||||
if (!this._poll.getValue() || !this._poll.getValue().slug || this._poll.getValue().slug !== wantedSlug) {
|
if (
|
||||||
await this.loadPollBySlug(wantedSlug);
|
!this._poll.getValue() ||
|
||||||
|
!this._poll.getValue().custom_url ||
|
||||||
|
this._poll.getValue().custom_url !== wantedcustom_url
|
||||||
|
) {
|
||||||
|
await this.loadPollBycustom_url(wantedcustom_url);
|
||||||
}
|
}
|
||||||
if (this._poll.getValue()) {
|
if (this._poll.getValue()) {
|
||||||
return this._poll.getValue();
|
return this._poll.getValue();
|
||||||
@ -72,25 +76,25 @@ export class PollService implements Resolve<Poll> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async loadPollBySlug(slug: string): Promise<void> {
|
public async loadPollBycustom_url(custom_url: string): Promise<void> {
|
||||||
console.log('slug', slug);
|
console.log('custom_url', custom_url);
|
||||||
if (slug) {
|
if (custom_url) {
|
||||||
const poll: Poll | undefined = await this.apiService.getPollBySlug(slug);
|
const poll: Poll | undefined = await this.apiService.getPollByCustomUrl(custom_url);
|
||||||
|
|
||||||
console.log({ loadPollBySlugResponse: poll });
|
console.log({ loadPollBycustom_urlResponse: poll });
|
||||||
if (poll) {
|
if (poll) {
|
||||||
this.updateCurrentPoll(poll);
|
this.updateCurrentPoll(poll);
|
||||||
this.titleService.setTitle(`☑️ ${poll.title} - ${environment.appTitle}`);
|
this.titleService.setTitle(`☑️ ${poll.title} - ${environment.appTitle}`);
|
||||||
} else {
|
} else {
|
||||||
this.toastService.display(`sondage ${slug} non trouvé`);
|
this.toastService.display(`sondage ${custom_url} non trouvé`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async loadPollBySlugWithPasswordHash(slug: string, hash: string): Promise<void> {
|
public async loadPollBycustom_urlWithPasswordHash(custom_url: string, hash: string): Promise<void> {
|
||||||
console.log('slug', slug);
|
console.log('custom_url', custom_url);
|
||||||
if (slug) {
|
if (custom_url) {
|
||||||
const poll: Poll | undefined = await this.apiService.getPollBySlugWithHash(slug, hash);
|
const poll: Poll | undefined = await this.apiService.getPollByCustomUrlWithHash(custom_url, hash);
|
||||||
console.log({ loadPollBySlugResponse: poll });
|
console.log({ loadPollBycustom_urlResponse: poll });
|
||||||
this.updateCurrentPoll(poll);
|
this.updateCurrentPoll(poll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,15 +102,17 @@ export class PollService implements Resolve<Poll> {
|
|||||||
public updateCurrentPoll(poll: Poll): void {
|
public updateCurrentPoll(poll: Poll): void {
|
||||||
this.storageService.setChoicesForVoteStack(poll.choices);
|
this.storageService.setChoicesForVoteStack(poll.choices);
|
||||||
|
|
||||||
|
this.toastService.display('sondage bien mis à jour', 'success');
|
||||||
|
|
||||||
console.log('poll', poll);
|
console.log('poll', poll);
|
||||||
this._poll.next(poll);
|
this._poll.next(poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* make a uniq slug for the current poll creation
|
* make a uniq custom_url for the current poll creation
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
makeSlug(config: Poll): string {
|
makecustom_url(config: Poll): string {
|
||||||
console.log('config', config);
|
console.log('config', config);
|
||||||
let str = '';
|
let str = '';
|
||||||
str =
|
str =
|
||||||
@ -152,80 +158,45 @@ export class PollService implements Resolve<Poll> {
|
|||||||
const currentPoll = this._poll.getValue();
|
const currentPoll = this._poll.getValue();
|
||||||
currentPoll.choices.find((c) => c.name === choice.name)?.updateParticipation(user, response);
|
currentPoll.choices.find((c) => c.name === choice.name)?.updateParticipation(user, response);
|
||||||
this.updateCurrentPoll(currentPoll);
|
this.updateCurrentPoll(currentPoll);
|
||||||
this.apiService.createParticipation(currentPoll.slug, choice.name, user.pseudo, response);
|
this.apiService.createParticipation(currentPoll.custom_url, choice.name, user.pseudo, response);
|
||||||
this.toastService.display('Votre participation au sondage a été enregistrée.');
|
this.toastService.display('Votre participation au sondage a été enregistrée.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteAllAnswers(): Promise<void> {
|
public async deleteAllAnswers(): Promise<void> {
|
||||||
await this.apiService.deletePollAnswers(this._poll.getValue().slug);
|
await this.apiService.deletePollAnswers(this._poll.getValue().custom_url);
|
||||||
this.toastService.display('Les participations des votants à ce sondage ont été supprimées.');
|
this.toastService.display('Les participations des votants à ce sondage ont été supprimées.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async addComment(comment: string): Promise<void> {
|
public async addComment(comment: string): Promise<void> {
|
||||||
await this.apiService.createComment(this._poll.getValue().slug, comment);
|
await this.apiService.createComment(this._poll.getValue().custom_url, comment);
|
||||||
this.toastService.display('Votre commentaire a été enregistré.');
|
this.toastService.display('Votre commentaire a été enregistré.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteComments(): Promise<void> {
|
public async deleteComments(): Promise<void> {
|
||||||
await this.apiService.deletePollComments(this._poll.getValue().slug);
|
await this.apiService.deletePollComments(this._poll.getValue().custom_url);
|
||||||
this.toastService.display('Les commentaires de ce sondage ont été supprimés.');
|
this.toastService.display('Les commentaires de ce sondage ont été supprimés.');
|
||||||
}
|
}
|
||||||
|
|
||||||
newPollFromForm(form: any): any {
|
|
||||||
const newpoll = new Poll(
|
|
||||||
this.userService.getCurrentUser(),
|
|
||||||
this.uuidService.getUUID(),
|
|
||||||
form.controls.title.value
|
|
||||||
);
|
|
||||||
/**
|
/**
|
||||||
* convert to API version 1 config poll
|
* @description convert to API version 1 data transition object
|
||||||
|
* @param form
|
||||||
*/
|
*/
|
||||||
const apiV1Poll = {
|
newPollFromForm(form: any): Poll {
|
||||||
menuVisible: true,
|
const newOwner = this.storageService.vote_stack.owner;
|
||||||
expiracyDateDefaultInDays: newpoll.configuration.expiresDaysDelay,
|
|
||||||
deletionDateAfterLastModification: newpoll.configuration.expiracyAfterLastModificationInDays,
|
|
||||||
pollType: newpoll.configuration.isAboutDate ? 'dates' : 'classic', // classic or dates
|
|
||||||
title: newpoll.title,
|
|
||||||
description: newpoll.description,
|
|
||||||
myName: newpoll.owner.pseudo,
|
|
||||||
myComment: '',
|
|
||||||
isAdmin: true, // when we create a poll, we are admin on it
|
|
||||||
myVoteStack: {},
|
|
||||||
myTempVoteStack: 0,
|
|
||||||
myEmail: newpoll.owner.email,
|
|
||||||
myPolls: [], // list of retrieved polls from the backend api
|
|
||||||
/*
|
|
||||||
date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates
|
|
||||||
*/
|
|
||||||
allowSeveralHours: 'true',
|
|
||||||
// access
|
|
||||||
visibility: newpoll.configuration.areResultsPublic, // visible to one with the link:
|
|
||||||
voteChoices: newpoll.configuration.isMaybeAnswerAvailable ? 'yes, maybe, no' : 'yes', // possible answers to a vote choice: only "yes", "yes, maybe, no"
|
|
||||||
creationDate: new Date(),
|
|
||||||
expirationDate: '', // expiracy date
|
|
||||||
voteStackId: null, // id of the vote stack to update
|
|
||||||
pollId: null, // id of the current poll when created. data given by the backend api
|
|
||||||
pollSlug: null, // id of the current poll when created. data given by the backend api
|
|
||||||
currentPoll: null, // current poll selected with createPoll or getPoll of ConfigService
|
|
||||||
passwordAccess: newpoll.configuration.isProtectedByPassword,
|
|
||||||
password: newpoll.configuration.password,
|
|
||||||
customUrl: newpoll.slug, // custom slug in the url, must be unique
|
|
||||||
customUrlIsUnique: null, // given by the backend
|
|
||||||
urlSlugPublic: null,
|
|
||||||
urlPublic: null,
|
|
||||||
urlAdmin: null,
|
|
||||||
adminKey: '', // key to change config of the poll
|
|
||||||
owner_modifier_token: '', // key to change a vote stack
|
|
||||||
canModifyAnswers: newpoll.configuration.isAllowingtoChangeOwnAnswers, // bool for the frontend selector
|
|
||||||
whoCanChangeAnswers: newpoll.configuration.whoCanChangeAnswers, // everybody, self, nobody (: just admin)
|
|
||||||
dateList: newpoll.dateChoices, // sets of days as strings, config to set identical time for days in a special days poll
|
|
||||||
timeList: newpoll.timeChoices, // ranges of time expressed as strings
|
|
||||||
|
|
||||||
answers: newpoll.choices,
|
const newpoll = new Poll(newOwner, form.value.custom_url, form.value.title);
|
||||||
// modals
|
|
||||||
displayConfirmVoteModalAdmin: false,
|
const pollKeys = Object.keys(newpoll);
|
||||||
};
|
const formFields = Object.keys(form.value);
|
||||||
console.log('apiV1Poll', apiV1Poll);
|
|
||||||
return apiV1Poll;
|
for (const fieldOfForm of formFields) {
|
||||||
|
if (pollKeys.indexOf(fieldOfForm) !== -1) {
|
||||||
|
newpoll[fieldOfForm] = form.value[fieldOfForm];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newpoll.expiracy_date = form.value.expiracy_date;
|
||||||
|
|
||||||
|
console.log('newpoll', newpoll);
|
||||||
|
return newpoll;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ export class PollUtilitiesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* make a uniq slug for the current poll creation
|
* make a uniq custom_url for the current poll creation
|
||||||
* @param str
|
* @param str
|
||||||
*/
|
*/
|
||||||
makeSlug(config: Poll) {
|
makeSlug(config: Poll) {
|
||||||
@ -37,7 +37,12 @@ export class PollUtilitiesService {
|
|||||||
config.creatorPseudo +
|
config.creatorPseudo +
|
||||||
'_' +
|
'_' +
|
||||||
config.title;
|
config.title;
|
||||||
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
|
||||||
|
return this.makeSlugFromString(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
makeSlugFromString(text: string): string {
|
||||||
|
let str = text.replace(/^\s+|\s+$/g, ''); // trim
|
||||||
str = str.toLowerCase();
|
str = str.toLowerCase();
|
||||||
|
|
||||||
// remove accents, swap ñ for n, etc
|
// remove accents, swap ñ for n, etc
|
||||||
@ -130,7 +135,7 @@ export class PollUtilitiesService {
|
|||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.setAttribute('href', encodedUri);
|
link.setAttribute('href', encodedUri);
|
||||||
const exportFileName =
|
const exportFileName =
|
||||||
(poll.urlPublic ? poll.urlPublic : this.makeSlug(poll)) + '_export_' + new Date() + '.csv';
|
(poll.custom_url ? poll.custom_url : this.makeSlug(poll)) + '_export_' + new Date() + '.csv';
|
||||||
link.setAttribute('download', exportFileName);
|
link.setAttribute('download', exportFileName);
|
||||||
document.body.appendChild(link); // Required for FF
|
document.body.appendChild(link); // Required for FF
|
||||||
link.click(); // This will download the data file named "my_data.csv".
|
link.click(); // This will download the data file named "my_data.csv".
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<p>
|
<p>
|
||||||
{{ 'creation.choose_title' | translate }}
|
{{ 'creation.choose_title' | translate }}
|
||||||
</p>
|
</p>
|
||||||
<h2 class="title is-2">slug: {{ form.value.slug }}</h2>
|
|
||||||
<br />
|
<br />
|
||||||
<label class="hidden" for="title">Titre</label>
|
<label class="hidden" for="title">Titre</label>
|
||||||
<input
|
<input
|
||||||
@ -29,6 +28,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
<p>
|
||||||
<label for="creatorPseudo">
|
<label for="creatorPseudo">
|
||||||
<span>
|
<span>
|
||||||
{{ 'creation.email' | translate }}
|
{{ 'creation.email' | translate }}
|
||||||
@ -43,9 +43,11 @@
|
|||||||
id="creatorEmail"
|
id="creatorEmail"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
</p>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<label class="" for="creatorEmail">
|
<p>
|
||||||
|
<label class="" for="creatorPseudo">
|
||||||
<span>
|
<span>
|
||||||
{{ 'creation.name' | translate }}
|
{{ 'creation.name' | translate }}
|
||||||
</span>
|
</span>
|
||||||
@ -58,6 +60,7 @@
|
|||||||
id="creatorPseudo"
|
id="creatorPseudo"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
@ -66,7 +69,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<img src="assets/img/undraw_Moving_twwf.svg" alt="image WIP" />
|
<!-- <img src="assets/img/undraw_Moving_twwf.svg" alt="image WIP" />-->
|
||||||
<div>
|
<div>
|
||||||
<h2>
|
<h2>
|
||||||
{{ 'choices.title' | translate }}
|
{{ 'choices.title' | translate }}
|
||||||
|
@ -8,6 +8,7 @@ import { Router } from '@angular/router';
|
|||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { Poll } from '../../../../core/models/poll.model';
|
import { Poll } from '../../../../core/models/poll.model';
|
||||||
import { environment } from '../../../../../environments/environment';
|
import { environment } from '../../../../../environments/environment';
|
||||||
|
import { PollUtilitiesService } from '../../../../core/services/poll.utilities.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-base-config',
|
selector: 'app-base-config',
|
||||||
@ -26,6 +27,7 @@ export class BaseConfigComponent {
|
|||||||
private uuidService: UuidService,
|
private uuidService: UuidService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private pollService: PollService,
|
private pollService: PollService,
|
||||||
|
private utilitiesService: PollUtilitiesService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
@Inject(DOCUMENT) private document: Document
|
@Inject(DOCUMENT) private document: Document
|
||||||
@ -52,11 +54,11 @@ export class BaseConfigComponent {
|
|||||||
if (this.form.valid) {
|
if (this.form.valid) {
|
||||||
console.log('Le sondage est correctement rempli, prêt à enregistrer.');
|
console.log('Le sondage est correctement rempli, prêt à enregistrer.');
|
||||||
const newpoll = this.pollService.newPollFromForm(this.form);
|
const newpoll = this.pollService.newPollFromForm(this.form);
|
||||||
// TODO : save the poll
|
|
||||||
|
|
||||||
this.apiService.createPoll(newpoll).then((resp) => {
|
this.apiService.createPoll(newpoll).then((resp) => {
|
||||||
console.log('resp', resp);
|
console.log('resp', resp);
|
||||||
router.navigate(['success']);
|
router.navigate(['success']);
|
||||||
|
|
||||||
|
this.toastService.display('sauvegarde du nouveau sondage réussie');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.toastService.display('invalid form');
|
this.toastService.display('invalid form');
|
||||||
@ -65,14 +67,14 @@ export class BaseConfigComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public updateSlug(): void {
|
public updateSlug(): void {
|
||||||
const newValueFormatted = 'TODO';
|
const newValueFormatted = this.pollService.makecustom_url(this.poll);
|
||||||
this.form.patchValue({ slug: newValueFormatted });
|
this.form.patchValue({ slug: newValueFormatted });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the poll slug from other data of the poll
|
* set the poll custom_url from other data of the poll
|
||||||
*/
|
*/
|
||||||
automaticSlug() {
|
automaticSlug() {
|
||||||
this.form.patchValue({ slug: this.pollService.makeSlug(this.form.value) });
|
this.form.patchValue({ slug: this.utilitiesService.makeUuid() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
<div class="admin-form padded">
|
<div class="admin-form padded">
|
||||||
|
<div class="container is-max-widescreen">
|
||||||
<form [formGroup]="form">
|
<form [formGroup]="form">
|
||||||
<header class="columns">
|
<header class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<h1>
|
<h1 class="title is-2">
|
||||||
{{ 'creation.title' | translate }}
|
{{ 'creation.title' | translate }}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<button
|
<button class="btn is-success" (click)="apiService.createPoll(poll)">
|
||||||
class="btn is-success"
|
<!-- [disabled]="!form.valid || !form.valid"-->
|
||||||
(click)="apiService.createPoll(poll)"
|
|
||||||
[disabled]="!form.valid || !form.valid"
|
|
||||||
>
|
|
||||||
<i class="fa fa-save"></i>
|
<i class="fa fa-save"></i>
|
||||||
Enregistrer le sondage
|
Enregistrer le sondage
|
||||||
</button>
|
</button>
|
||||||
@ -19,14 +17,28 @@
|
|||||||
</header>
|
</header>
|
||||||
<main class="columns">
|
<main class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<p class="subtitle">
|
<p class="label is-medium">
|
||||||
{{ 'creation.want' | translate }}
|
{{ 'creation.want' | translate }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<app-kind-select [form]="form"></app-kind-select>
|
<app-kind-select [form]="form"></app-kind-select>
|
||||||
|
|
||||||
|
<div class="field is-grouped is-grouped-right">
|
||||||
|
<p class="control">
|
||||||
|
<a class="button is-light" (click)="goPreviousStep()">
|
||||||
|
Précédent
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p class="control">
|
||||||
|
<a class="button is-primary" (click)="goNextStep()">
|
||||||
|
Suivant
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<app-base-config [form]="form"></app-base-config>
|
<app-base-config [form]="form"></app-base-config>
|
||||||
<!-- <app-date-select-->
|
<!-- <app-date-select-->
|
||||||
<!-- *ngIf="form.value.configuration && form.value.configuration.isAboutDate"-->
|
<!-- *ngIf="form.value.configuration && form.value.kind == 'date'"-->
|
||||||
<!-- [form]="form"-->
|
<!-- [form]="form"-->
|
||||||
<!-- ></app-date-select>-->
|
<!-- ></app-date-select>-->
|
||||||
<!-- <app-text-select ng-if="!form.value.isAboutDate" [form]="form"></app-text-select>-->
|
<!-- <app-text-select ng-if="!form.value.isAboutDate" [form]="form"></app-text-select>-->
|
||||||
@ -39,7 +51,11 @@
|
|||||||
<i class="fa fa-save"></i>
|
<i class="fa fa-save"></i>
|
||||||
{{ 'creation.advanced' | translate }}
|
{{ 'creation.advanced' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<app-advanced-config [poll]="poll" [form]="form" *ngIf="advancedDisplayEnabled"></app-advanced-config>
|
<app-advanced-config
|
||||||
|
[poll]="poll"
|
||||||
|
[form]="form"
|
||||||
|
*ngIf="advancedDisplayEnabled"
|
||||||
|
></app-advanced-config>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer class="column" *ngIf="show_debug_data">
|
<footer class="column" *ngIf="show_debug_data">
|
||||||
@ -66,4 +82,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
@import '../../../../styles/variables';
|
@import '../../../../styles/variables';
|
||||||
:host {
|
:host {
|
||||||
input,
|
.admin-form {
|
||||||
textarea {
|
max-width: 800px;
|
||||||
padding: 0.5em;
|
margin: 0 auto;
|
||||||
border: solid #eee;
|
|
||||||
|
|
||||||
width: 90%;
|
|
||||||
}
|
|
||||||
.form-field {
|
|
||||||
display: block;
|
|
||||||
margin-top: 1em;
|
|
||||||
}
|
}
|
||||||
.form-row {
|
.form-row {
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
@ -75,6 +68,11 @@
|
|||||||
.example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder) {
|
.example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder) {
|
||||||
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
|
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
|
||||||
}
|
}
|
||||||
|
.ng-pristine,
|
||||||
|
.ng-dirty {
|
||||||
|
border-left: $white 3px solid;
|
||||||
|
padding-left: 1em;
|
||||||
|
}
|
||||||
.ng-touched.ng-invalid {
|
.ng-touched.ng-invalid {
|
||||||
border-left: $danger 3px solid;
|
border-left: $danger 3px solid;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
|
@ -7,6 +7,8 @@ import { ToastService } from '../../../core/services/toast.service';
|
|||||||
import { PollService } from '../../../core/services/poll.service';
|
import { PollService } from '../../../core/services/poll.service';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { environment } from '../../../../environments/environment';
|
||||||
|
import { PollUtilitiesService } from '../../../core/services/poll.utilities.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-admin-form',
|
selector: 'app-admin-form',
|
||||||
@ -24,7 +26,7 @@ export class FormComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private cd: ChangeDetectorRef,
|
private cd: ChangeDetectorRef,
|
||||||
private uuidService: UuidService,
|
private pollUtilitiesService: PollUtilitiesService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private pollService: PollService,
|
private pollService: PollService,
|
||||||
public apiService: ApiService,
|
public apiService: ApiService,
|
||||||
@ -39,14 +41,14 @@ export class FormComponent implements OnInit {
|
|||||||
console.log('pollsAvailable', pollsAvailable);
|
console.log('pollsAvailable', pollsAvailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
initFormDefault(showDemoValues = true): void {
|
initFormDefault(showDemoValues = environment.autofill): void {
|
||||||
const creationDate = new Date();
|
const creationDate = new Date();
|
||||||
|
|
||||||
this.form = this.fb.group({
|
this.form = this.fb.group({
|
||||||
title: ['', [Validators.required, Validators.minLength(12)]],
|
title: ['', [Validators.required, Validators.minLength(12)]],
|
||||||
creatorPseudo: ['', [Validators.required]],
|
creatorPseudo: ['', [Validators.required]],
|
||||||
creatorEmail: ['', [Validators.required]],
|
creatorEmail: ['', [Validators.required]],
|
||||||
slug: [this.uuidService.getUUID(), [Validators.required]],
|
custom_url: [this.pollUtilitiesService.makeUuid(), [Validators.required]],
|
||||||
description: ['', [Validators.required]],
|
description: ['', [Validators.required]],
|
||||||
choices: this.fb.array([
|
choices: this.fb.array([
|
||||||
this.fb.group({
|
this.fb.group({
|
||||||
@ -84,7 +86,7 @@ export class FormComponent implements OnInit {
|
|||||||
expiresDaysDelay: [60, [Validators.required, Validators.min(1)]],
|
expiresDaysDelay: [60, [Validators.required, Validators.min(1)]],
|
||||||
maxCountOfAnswers: [150, [Validators.required, Validators.min(1)]],
|
maxCountOfAnswers: [150, [Validators.required, Validators.min(1)]],
|
||||||
allowComments: [true, [Validators.required]],
|
allowComments: [true, [Validators.required]],
|
||||||
password: [this.uuidService.getUUID(), [Validators.required]],
|
password: [this.pollUtilitiesService.makeUuid(), [Validators.required]],
|
||||||
dateCreated: [creationDate, [Validators.required]],
|
dateCreated: [creationDate, [Validators.required]],
|
||||||
hasSeveralHours: [true, [Validators.required]],
|
hasSeveralHours: [true, [Validators.required]],
|
||||||
hasMaxCountOfAnswers: [true, [Validators.required, Validators.min(1)]],
|
hasMaxCountOfAnswers: [true, [Validators.required, Validators.min(1)]],
|
||||||
@ -104,10 +106,11 @@ export class FormComponent implements OnInit {
|
|||||||
* add example values to the form, overrides defaults of PollConfiguration
|
* add example values to the form, overrides defaults of PollConfiguration
|
||||||
*/
|
*/
|
||||||
setDemoValues(): void {
|
setDemoValues(): void {
|
||||||
|
const title = 'le titre de démo oh oh';
|
||||||
this.form.patchValue({
|
this.form.patchValue({
|
||||||
title: 'le titre de démo oh oh',
|
title: title,
|
||||||
|
custom_url: this.pollUtilitiesService.makeSlugFromString(title),
|
||||||
description: 'répondez SVP <3 ! *-* ',
|
description: 'répondez SVP <3 ! *-* ',
|
||||||
slug: this.uuidService.getUUID(),
|
|
||||||
creatorPseudo: 'Chuck Norris',
|
creatorPseudo: 'Chuck Norris',
|
||||||
creatorEmail: 'chucknorris@example.com',
|
creatorEmail: 'chucknorris@example.com',
|
||||||
isAboutDate: true,
|
isAboutDate: true,
|
||||||
@ -124,9 +127,25 @@ export class FormComponent implements OnInit {
|
|||||||
expiresDaysDelay: 60,
|
expiresDaysDelay: 60,
|
||||||
},
|
},
|
||||||
comments: [],
|
comments: [],
|
||||||
choices: [],
|
choices: [
|
||||||
dateChoices: [],
|
{
|
||||||
|
name: 'un choix',
|
||||||
|
url: 'https://placekitten.com/120/150',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dateChoices: [
|
||||||
|
{
|
||||||
|
name: new Date(),
|
||||||
|
},
|
||||||
|
],
|
||||||
timeChoices: [],
|
timeChoices: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goPreviousStep() {
|
||||||
|
alert('todo');
|
||||||
|
}
|
||||||
|
goNextStep() {
|
||||||
|
alert('todo');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div class="kind-select form-field">
|
<div class="kind-select form-field">
|
||||||
<form [formGroup]="form">
|
<form [formGroup]="form">
|
||||||
<div class="kind-of-poll columns">
|
<div class="kind-of-poll control">
|
||||||
<div class="column" *ngIf="template_questions_answers">
|
<div class="select" *ngIf="template_questions_answers">
|
||||||
<!-- version maquette questions réponses-->
|
<!-- version maquette questions réponses-->
|
||||||
<select name="type" id="type" class="input" formControlName="kind">
|
<select name="type" id="type" class="input" formControlName="kind">
|
||||||
<option [value]="'date'">{{ 'creation.kind.date' | translate }}</option>
|
<option [value]="'date'">{{ 'creation.kind.date' | translate }}</option>
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn btn--primary btn-block submit-votestack update"
|
class="btn btn--primary btn-block submit-votestack update"
|
||||||
(click)="updateVote(storageService.vote_stack)"
|
(click)="updateVoteStack(storageService.vote_stack)"
|
||||||
*ngIf="storageService.vote_stack && storageService.vote_stack.id"
|
*ngIf="storageService.vote_stack && storageService.vote_stack.id"
|
||||||
>
|
>
|
||||||
<i class="fa fa-edit" aria-hidden="true"></i> Mettre à jour
|
<i class="fa fa-edit" aria-hidden="true"></i> Mettre à jour
|
||||||
|
@ -80,13 +80,20 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVote(votestack: Stack) {
|
updateVoteStack(vote_stack: Stack): void {
|
||||||
alert('TODO');
|
alert('TODO');
|
||||||
|
this.api.sendUpdateVoteStack(vote_stack).then((resp) => {
|
||||||
|
console.log('sendUpdateVoteStack resp', resp);
|
||||||
|
|
||||||
|
this.toastService.display('vote bien mis à jour', 'success');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addVoteStack() {
|
addVoteStack(): void {
|
||||||
this.api.sendVoteStackOfPoll(this.poll, this.storageService.vote_stack).subscribe((resp) => {
|
this.api.sendNewVoteStackOfPoll(this.poll, this.storageService.vote_stack).subscribe((resp) => {
|
||||||
console.log('sendVoteStackOfPoll resp', resp);
|
console.log('sendNewVoteStackOfPoll resp', resp);
|
||||||
|
|
||||||
|
this.toastService.display('vote ajouté', 'success');
|
||||||
|
|
||||||
if (resp) {
|
if (resp) {
|
||||||
this.api.getPollBySlug(this.poll.custom_url);
|
this.api.getPollBySlug(this.poll.custom_url);
|
||||||
@ -99,19 +106,19 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* export all the poll data available to the public as a CSV single file
|
* export all the poll data available to the public as a CSV single file
|
||||||
*/
|
*/
|
||||||
exportCSV() {
|
exportCSV(): void {
|
||||||
this.utils.exportCSV(this.poll);
|
this.utils.exportCSV(this.poll);
|
||||||
}
|
}
|
||||||
|
|
||||||
exportJson() {
|
exportJson(): void {
|
||||||
this.utils.download('export_poll_' + this.pollSlug + '.json', JSON.stringify(this.poll));
|
this.utils.download('export_poll_' + this.pollSlug + '.json', JSON.stringify(this.poll));
|
||||||
}
|
}
|
||||||
|
|
||||||
duplicate() {
|
duplicate(): void {
|
||||||
alert('TODO');
|
alert('TODO');
|
||||||
}
|
}
|
||||||
|
|
||||||
print() {
|
print(): void {
|
||||||
alert('TODO');
|
alert('TODO');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,18 +22,18 @@ export const routes: Routes = [
|
|||||||
// resolve: {poll: PollService},
|
// resolve: {poll: PollService},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'poll/:slug/administration',
|
path: 'poll/:custom_url/administration',
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
import('./features/administration/administration.module').then((m) => m.AdministrationModule),
|
import('./features/administration/administration.module').then((m) => m.AdministrationModule),
|
||||||
// resolve: { poll: PollService },
|
// resolve: { poll: PollService },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'poll/:slug/consultation',
|
path: 'poll/:custom_url/consultation',
|
||||||
loadChildren: () => import('./features/consultation/consultation.module').then((m) => m.ConsultationModule),
|
loadChildren: () => import('./features/consultation/consultation.module').then((m) => m.ConsultationModule),
|
||||||
// resolve: { poll: PollService },
|
// resolve: { poll: PollService },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'poll/:slug/participation',
|
path: 'poll/:custom_url/participation',
|
||||||
loadChildren: () => import('./features/participation/participation.module').then((m) => m.ParticipationModule),
|
loadChildren: () => import('./features/participation/participation.module').then((m) => m.ParticipationModule),
|
||||||
// resolve: { poll: PollService },
|
// resolve: { poll: PollService },
|
||||||
},
|
},
|
||||||
|
@ -14,6 +14,7 @@ export const environment = {
|
|||||||
production: true,
|
production: true,
|
||||||
display_routes: true,
|
display_routes: true,
|
||||||
autofill: true,
|
autofill: true,
|
||||||
|
autoSendNewPoll: false,
|
||||||
appTitle: 'FramaDate Funky',
|
appTitle: 'FramaDate Funky',
|
||||||
appVersion: '2.1.0',
|
appVersion: '2.1.0',
|
||||||
appLogo: 'assets/img/logo.png',
|
appLogo: 'assets/img/logo.png',
|
||||||
|
@ -18,9 +18,10 @@ const apiV1 = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: true,
|
production: false,
|
||||||
display_routes: true,
|
display_routes: true,
|
||||||
autofill: true,
|
autofill: true,
|
||||||
|
autoSendNewPoll: true,
|
||||||
appTitle: 'FramaDate Funky',
|
appTitle: 'FramaDate Funky',
|
||||||
appVersion: '2.1.0',
|
appVersion: '2.1.0',
|
||||||
appLogo: 'assets/img/logo.png',
|
appLogo: 'assets/img/logo.png',
|
||||||
|
@ -19,13 +19,15 @@ option {
|
|||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
background-image: url('/assets/img/fleche_bas.svg');
|
//background-image: url('/assets/img/fleche_bas.svg');
|
||||||
padding-right: 2.5rem;
|
padding-right: 2.5rem;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: 9px 8px;
|
background-size: 9px 8px;
|
||||||
background-position: right 1rem center;
|
background-position: right 1rem center;
|
||||||
background-clip: border-box;
|
background-clip: border-box;
|
||||||
min-width: 10rem;
|
min-width: 10rem;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
border-bottom: 2px solid $primary_color !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user