diff --git a/webpack/component/ue/manage.vue b/webpack/component/ue/manage.vue
index e7534a3..bd5f615 100644
--- a/webpack/component/ue/manage.vue
+++ b/webpack/component/ue/manage.vue
@@ -4,7 +4,31 @@
-
+
+
+
+
+
+
@@ -21,7 +45,7 @@
v-for='(c,i) in gstore.manage.cours'
:data-id='c.idCours'>
-
+
+
+
+
+
diff --git a/webpack/data/ue.js b/webpack/data/ue.js
index 7bff1fc..ce7be8b 100644
--- a/webpack/data/ue.js
+++ b/webpack/data/ue.js
@@ -403,14 +403,6 @@ gstore.add('ie_handler', function(ue_i){
if( vco === '' || isNaN(vco) || vco < 0 )
errors.push('Le volume horaire de cours doit être un entier positif.');
- /* (5.5.5) Check TD */
- if( vtd === '' || isNaN(vtd) || vtd < 0 )
- errors.push('Le volume horaire de TD doit être un entier positif.');
-
- /* (5.5.6) Check TP */
- if( vtp === '' || isNaN(vtp) || vtp < 0 )
- errors.push('Le volume horaire de TP doit être un entier positif.');
-
/* (5.6) Show first error only (for 2s) */
if( errors.length > 0 ){
@@ -996,4 +988,101 @@ gstore.add('rem', function(type, res_i){
});
-});
\ No newline at end of file
+});
+
+
+/* (2) Create a Cours|TD|TP */
+gstore.add('ccrea', {
+ type: '-',
+ prof: -1,
+ vol: '',
+ err: '',
+ valid: false
+});
+
+gstore.add('ccreate', function(){
+
+ /* (1) Trim text input */
+ gstore.get.ccrea.vol = gstore.get.ccrea.vol.trim();
+
+ /* (2) Store values locally */
+ var type = gstore.get.ccrea.type;
+ var prof = gstore.get.ccrea.prof;
+ var vol = gstore.get.ccrea.vol;
+
+ /* (2) Init client-side check */
+ var errors = [];
+
+ /* (2.1) Check type */
+ if( isNaN(type) || [0,1,2].indexOf(parseInt(type)) <= -1 )
+ errors.push('Le type de prestation est manquant (Cours, TD, TP)');
+
+ /* (2.2) Check prof */
+ if( isNaN(prof) )
+ errors.push('L\'enseignant est invalide ou manquant');
+
+ /* (2.3) Check volume */
+ if( vol === '' || isNaN(vol) || vol < 0 )
+ errors.push('Le volume horaire doit être un entier positif.');
+
+ /* (2.4) Show first error only (for 2s) */
+ if( errors.length > 0 ){
+
+ gstore.get.ccrea.valid = false;
+ gstore.get.ccrea.err = errors[0];
+
+ return setTimeout(() => gstore.add('ccrea.err', ''), 2000);
+
+ }
+
+ /* (3) Extract resource type */
+ var restyp = ['cours', 'td', 'tp'][type];
+ var restyp2 = ['Cours', 'TD', 'TP'][type];
+
+ /* (4) Create request */
+ var rq = {
+ code: gstore.get.URI[2],
+ volume: parseInt(vol)
+ };
+
+ // optional 'idProf'
+ ( prof > -1 ) && ( rq.idProf = parseInt(prof) );
+
+
+ /* (5) Send request */
+ api.call(`POST ue/${restyp}`, rq, function(rs){
+
+ console.log(rs);
+
+ /* (5.1) Manage errors */
+ if( rs.error !== 0 ){
+ gstore.get.ccrea.valid = false
+ gstore.get.create_err = `erreur (${rs.error}) Impossible de créer le ${restyp}`;
+ return setTimeout(() => gstore.add('create_err', ''), 2000);
+ }
+
+ /* (5.2) Show that Cours|TD|TP is created */
+ gstore.get.ccrea.valid = true;
+ gstore.get.ccrea.err = `Le ${restyp} a bien été créé, rechargez la page pour le visualiser.`;
+ setTimeout(() => gstore.add('create_err', ''), 2000);
+
+ /* (5.3) Empty fields */
+ // empty fields
+ gstore.get.ccrea.prof = -1;
+ gstore.get.ccrea.type = '-';
+ gstore.get.ccrea.vol = '';
+
+ /* (5.4) Add resource to list (update VueJS) */
+ var newRes = {};
+ newRes[`id${restyp2}`] = rs.created_id;
+ newRes[`idProf`] = prof;
+ newRes[`volume`] = vol;
+ newRes[`formations`] = [];
+ newRes[`add_form`] = '-';
+ newRes[`new_prof`] = prof;
+
+ gstore.get.manage[restyp].push(newRes);
+
+ });
+
+});
diff --git a/webpack/scss/container/card.scss b/webpack/scss/container/card.scss
index c49ddd9..4d496f7 100644
--- a/webpack/scss/container/card.scss
+++ b/webpack/scss/container/card.scss
@@ -236,7 +236,7 @@
margin: 0;
padding: 0;
margin-left: -.4em; // emulate no
- margin-top: -1em; // replace as if not a select
+ margin-top: -1em; // replace as if not a select
margin-bottom: -.3em; // fix layout for following elements
// remove border
diff --git a/webpack/scss/container/list.scss b/webpack/scss/container/list.scss
index 32d75ea..29fb90f 100644
--- a/webpack/scss/container/list.scss
+++ b/webpack/scss/container/list.scss
@@ -42,7 +42,8 @@
flex-wrap: nowrap;
/* (1.1) Element item */
- & > div:not(.icon){
+ & > div:not(.icon),
+ & > input{
flex: 1 1 0;
// fix
@@ -69,7 +70,6 @@
display: inline-block;
position: relative;
height: 1.8em;
- width: auto;
margin: 0;
margin-right: 1em;
@@ -91,12 +91,25 @@
-moz-appearance: none;
appearance: none;
- justify-self: space-around;
flex: 0 1 20em;
+ &.min{ flex: 0 1 5em; }
+
}
- /* (1.4) Icon (remove) */
+ /* (1.4) Input */
+ & > input{
+ display: inline-block;
+ position: relative;
+ min-width: 0;
+
+ margin: 0;
+ padding: .22em .5em;
+
+ flex: 0 1 5em;
+ }
+
+ /* (1.5) Icon (remove) */
& > div.icon{
display: inline-block;
width: 1.2em;
@@ -104,14 +117,19 @@
margin-right: 1em;
- background: url('/asset/svg/cross.svg@aaaaaa') center center no-repeat;
+ background: url('/asset/svg/plus.svg@aaaaaa') center center no-repeat;
background-size: 60% auto;
overflow: hidden;
cursor: pointer;
- &:hover{ background-image: url('/asset/svg/cross.svg@#{$rd-form-invalid-color}'); }
+ &:hover{ background-image: url('/asset/svg/plus.svg@#{$rd-form-valid-color}'); }
+
+ &.remove{
+ background-image: url('/asset/svg/cross.svg@aaaaaa');
+ &:hover{ background-image: url('/asset/svg/cross.svg@#{$rd-form-invalid-color}'); }
+ }
}
}
diff --git a/webpack/scss/global/before-icon.scss b/webpack/scss/global/before-icon.scss
index d41948c..d2a3097 100644
--- a/webpack/scss/global/before-icon.scss
+++ b/webpack/scss/global/before-icon.scss
@@ -28,6 +28,10 @@
// force red text
&.invalid{ color: $form-invalid-color; }
+
+ &[data-valid='1']{ color: $form-valid-color; }
+ &[data-neutral='1']{ color: $form-neutral-color; }
+ &[data-search='1']{ color: $form-search-color; }
}
diff --git a/webpack/scss/global/tag.scss b/webpack/scss/global/tag.scss
index b690462..9c7e0b9 100644
--- a/webpack/scss/global/tag.scss
+++ b/webpack/scss/global/tag.scss
@@ -33,6 +33,7 @@
color: #999;
font-size: .8em;
+ white-space: nowrap;
cursor: default;