Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 3 additions & 76 deletions admin/app/components/campaigns/update.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,14 @@
import Component from '@glimmer/component';
import Object, { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { validator, buildValidations } from 'ember-cp-validations';
import { getOwner } from '@ember/application';
import { action } from '@ember/object';
import { service } from '@ember/service';

const Validations = buildValidations({
name: {
validators: [
validator('presence', {
presence: true,
message: 'Le nom ne peut pas être vide',
}),
validator('length', {
min: 1,
max: 255,
message: 'La longueur du nom ne doit pas excéder 255 caractères',
}),
],
},
title: {
validators: [
validator('length', {
min: 0,
max: 50,
message: 'La longueur du titre ne doit pas excéder 50 caractères',
}),
],
},
customLandingPageText: {
validators: [
validator('length', {
min: 0,
max: 5000,
message: "La longueur du texte de la page d'accueil ne doit pas excéder 5000 caractères",
}),
],
},
customResultPageText: {
validators: [
validator('length', {
min: 0,
max: 5000,
message: 'La longueur du texte de la page de résultat ne doit pas excéder 5000 caractères',
}),
],
},
customResultPageButtonText: {
validators: [
validator('length', {
min: 0,
max: 255,
message: 'La longueur du texte ne doit pas excéder 255 caractères',
}),
],
},
customResultPageButtonUrl: {
validators: [
validator('format', {
type: 'url',
allowBlank: true,
message: 'Ce champ doit être une URL complète et valide',
}),
],
},
});

class Form extends Object.extend(Validations) {
@tracked name;
@tracked title;
@tracked customLandingPageText;
@tracked customResultPageText;
@tracked customResultPageButtonText;
@tracked customResultPageButtonUrl;
@tracked multipleSendings;
}

export default class Update extends Component {
@service notifications;
@service store;

constructor() {
super(...arguments);
this.form = Form.create(getOwner(this).ownerInjection());
this.form = this.store.createRecord('campaign-form');
this.form.name = this.args.campaign.name;
this.form.title = this.args.campaign.title;
this.form.customLandingPageText = this.args.campaign.customLandingPageText;
Expand Down
110 changes: 11 additions & 99 deletions admin/app/components/certification-centers/information-edit.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,16 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { buildValidations, validator } from 'ember-cp-validations';
import { getOwner } from '@ember/application';
import Object, { action } from '@ember/object';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { types } from '../../models/certification-center';

const Validations = buildValidations({
name: {
validators: [
validator('presence', {
presence: true,
ignoreBlank: true,
message: 'Le nom ne peut pas être vide',
}),
validator('length', {
min: 1,
max: 255,
message: 'La longueur du nom ne doit pas excéder 255 caractères',
}),
],
},
type: {
validators: [
validator('presence', {
presence: true,
ignoreBlank: true,
message: 'Le type ne peut pas être vide',
}),
],
},
externalId: {
validators: [
validator('length', {
min: 0,
max: 255,
message: "La longueur de l'identifiant externe ne doit pas excéder 255 caractères",
}),
],
},
dataProtectionOfficerFirstName: {
validators: [
validator('length', {
min: 0,
max: 255,
message: 'La longueur du prénom du DPO ne doit pas excéder 255 caractères',
}),
],
},
dataProtectionOfficerLastName: {
validators: [
validator('length', {
min: 0,
max: 255,
message: 'La longueur du nom du DPO ne doit pas excéder 255 caractères',
}),
],
},
dataProtectionOfficerEmail: {
validators: [
validator('length', {
max: 255,
message: "La longueur de l'adresse e-mail du DPO ne doit pas excéder 255 caractères.",
}),
validator('format', {
allowBlank: true,
type: 'email',
message: "L'adresse e-mail du DPO n'a pas le bon format.",
}),
],
},
});

class Form extends Object.extend(Validations) {
@tracked name;
@tracked externalId;
@tracked type;
@tracked habilitations;
}

export default class InformationEdit extends Component {
@service store;
certificationCenterTypes = types;

constructor() {
super(...arguments);
this.form = Form.create(getOwner(this).ownerInjection());
this.form = this.store.createRecord('certification-center-form');

this._initForm();
}

Expand All @@ -93,7 +20,7 @@ export default class InformationEdit extends Component {

@action
selectCertificationCenterType(value) {
this.form.type = value;
this.form.set('type', value ? value.trim() : value);
}

@action
Expand All @@ -115,9 +42,9 @@ export default class InformationEdit extends Component {
return;
}

this.args.certificationCenter.set('name', this.form.name.trim());
this.args.certificationCenter.set('externalId', !this.form.externalId ? null : this.form.externalId.trim());
this.args.certificationCenter.set('type', this.form.type.trim());
this.args.certificationCenter.set('name', this.form.name);
this.args.certificationCenter.set('externalId', !this.form.externalId ? null : this.form.externalId);
this.args.certificationCenter.set('type', this.form.type);
this.args.certificationCenter.set('habilitations', this.form.habilitations);
this.args.certificationCenter.set('dataProtectionOfficerFirstName', this.form.dataProtectionOfficerFirstName);
this.args.certificationCenter.set('dataProtectionOfficerLastName', this.form.dataProtectionOfficerLastName);
Expand All @@ -128,15 +55,7 @@ export default class InformationEdit extends Component {
}

_initForm() {
const {
habilitations,
name,
externalId,
type,
dataProtectionOfficerFirstName,
dataProtectionOfficerLastName,
dataProtectionOfficerEmail,
} = this.args.certificationCenter.getProperties(
const properties = this.args.certificationCenter.getProperties(
'habilitations',
'name',
'externalId',
Expand All @@ -145,13 +64,6 @@ export default class InformationEdit extends Component {
'dataProtectionOfficerLastName',
'dataProtectionOfficerEmail',
);

this.form.name = name;
this.form.habilitations = habilitations ? habilitations.toArray() : [];
this.form.externalId = externalId;
this.form.type = type;
this.form.dataProtectionOfficerFirstName = dataProtectionOfficerFirstName;
this.form.dataProtectionOfficerLastName = dataProtectionOfficerLastName;
this.form.dataProtectionOfficerEmail = dataProtectionOfficerEmail;
this.form.setProperties(properties);
}
}
132 changes: 3 additions & 129 deletions admin/app/components/organizations/information-section-edit.js
Original file line number Diff line number Diff line change
@@ -1,137 +1,11 @@
import Object, { action } from '@ember/object';
import { action } from '@ember/object';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { validator, buildValidations } from 'ember-cp-validations';
import { getOwner } from '@ember/application';

const Validations = buildValidations({
name: {
validators: [
validator('presence', {
presence: true,
ignoreBlank: true,
message: 'Le nom ne peut pas être vide',
}),
validator('length', {
min: 1,
max: 255,
message: 'La longueur du nom ne doit pas excéder 255 caractères',
}),
],
},
externalId: {
validators: [
validator('length', {
min: 0,
max: 255,
message: "La longueur de l'identifiant externe ne doit pas excéder 255 caractères",
}),
],
},
provinceCode: {
validators: [
validator('length', {
min: 0,
max: 255,
message: 'La longueur du département ne doit pas excéder 255 caractères',
}),
],
},
dataProtectionOfficerFirstName: {
validators: [
validator('length', {
max: 255,
message: 'La longueur du prénom ne doit pas excéder 255 caractères.',
}),
],
},
dataProtectionOfficerLastName: {
validators: [
validator('length', {
max: 255,
message: 'La longueur du nom ne doit pas excéder 255 caractères.',
}),
],
},
dataProtectionOfficerEmail: {
validators: [
validator('length', {
max: 255,
message: "La longueur de l'email ne doit pas excéder 255 caractères.",
}),
validator('format', {
allowBlank: true,
type: 'email',
message: "L'e-mail n'a pas le bon format.",
}),
],
},
email: {
validators: [
validator('length', {
max: 255,
message: "La longueur de l'email ne doit pas excéder 255 caractères.",
}),
validator('format', {
allowBlank: true,
type: 'email',
message: "L'e-mail n'a pas le bon format.",
}),
],
},
credit: {
validators: [
validator('number', {
allowString: true,
integer: true,
positive: true,
message: 'Le nombre de crédits doit être un nombre supérieur ou égal à 0.',
}),
],
},
isManagingStudents: {
validators: [
validator('inclusion', {
in: [true, false],
}),
],
},
documentationUrl: {
validators: [
validator('absolute-url', {
allowBlank: true,
message: "Le lien n'est pas valide.",
}),
],
},
showSkills: {
validators: [
validator('inclusion', {
in: [true, false],
}),
],
},
});

class Form extends Object.extend(Validations) {
@tracked name;
@tracked externalId;
@tracked provinceCode;
@tracked dataProtectionOfficerFirstName;
@tracked dataProtectionOfficerLastName;
@tracked dataProtectionOfficerEmail;
@tracked email;
@tracked credit;
@tracked isManagingStudents;
@tracked documentationUrl;
@tracked showSkills;
@tracked identityProviderForCampaigns;
@tracked enableMultipleSendingAssessement;
}

export default class OrganizationInformationSectionEditionMode extends Component {
@service accessControl;
@service store;
@service oidcIdentityProviders;

@tracked isEditMode = false;
Expand All @@ -141,7 +15,7 @@ export default class OrganizationInformationSectionEditionMode extends Component

constructor() {
super(...arguments);
this.form = Form.create(getOwner(this).ownerInjection());
this.form = this.store.createRecord('organization-form');
this._initForm();
}

Expand Down
Loading