[webpack.teacher.view] can now CREATE professors
This commit is contained in:
parent
0b5272c8ec
commit
e818886972
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
enable-background="new 0 0 44 43"
|
||||
height="43px"
|
||||
id="Layer_1"
|
||||
version="1.1"
|
||||
viewBox="0 0 44 43"
|
||||
width="44px"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="admin.svg"
|
||||
inkscape:version="0.92.2 5c3e80d, 2017-08-06"><metadata
|
||||
id="metadata9"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs7" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1015"
|
||||
id="namedview5"
|
||||
showgrid="false"
|
||||
inkscape:zoom="5.4883721"
|
||||
inkscape:cx="22"
|
||||
inkscape:cy="21.5"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="29"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1" /><path
|
||||
d="m 14.113324,21.173 c -1.835,-5.235 -1.049,-12.14 3.431,-16.62 6.054,-6.053 15.841,-6.08 21.893,-0.027 6.054,6.053 6.094,15.908 0.041,21.961 -4.615,4.615 -11.168,5.945 -17.026,3.318 l -2.902,2.902 -0.109,0.109 -4.084,-0.714 0.018,4.271 -4.244,0.008 0.532,4.213 -2.1109998,2.111 c -0.006,0.006 -0.006,0.006 -0.01,0.01 l -0.157,-0.156 c -0.741,0.673 -0.504,0.366 -0.615,0.366 l -7.272,0.22 c -0.6,0 -1.126,-0.443 -1.127,-1.044 l 0.283,-7.333 c 0,-0.112 -0.327,0.146 0.346,-0.596 l 0.058,0.059 c 0.003,-0.004 0.003,-0.003 0.006,-0.007 z m 16.773,-7.471 c 1.563,1.563 4.095,1.563 5.657,0 1.562,-1.563 1.563,-4.094 0,-5.657 -1.563,-1.563 -4.095,-1.563 -5.657,0 -1.562,1.563 -1.563,4.095 0,5.657 z"
|
||||
id="fill-edit"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#231f20" /></svg>
|
After Width: | Height: | Size: 2.2 KiB |
|
@ -8,25 +8,26 @@
|
|||
|
||||
<section class='valid' data-create=''>
|
||||
|
||||
<select class='category'>
|
||||
<option selected='selected' disabled='disabled'>Catégorie d'enseignant</option>
|
||||
<select class='category' v-model='gstore.create_cat'>
|
||||
<option selected='selected' disabled='disabled' value='-'>Catégorie d'enseignant</option>
|
||||
<option v-for='cat in gstore.categories' :value='cat.idCategorie'>{{ cat.labelCategorie }}</option>
|
||||
</select>
|
||||
<h1>
|
||||
<input type='text' placeholder='Prénom Nom' value=''>
|
||||
<input type='text' placeholder='Prénom Nom' v-model='gstore.create_name'>
|
||||
<span data-visible='1'><input type='text' placeholder='identifiant' v-model='gstore.create_cas'></span>
|
||||
</h1>
|
||||
|
||||
<div class='table'>
|
||||
<div>
|
||||
<span><input type='text' placeholder='???' value=''></span>
|
||||
<span><input type='text' placeholder='???' v-model='gstore.create_h'></span>
|
||||
<span>heures à faire</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='sub'> </div>
|
||||
<div :class="gstore.create_err.length > 0 ? 'sub warning' : 'sub'">{{ gstore.create_err }}</div>
|
||||
|
||||
<div class='footer'>
|
||||
<button class='valid'>Créer l'enseignant</button>
|
||||
<button class='valid' @click='gstore.ic_handler()'>Créer l'enseignant</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
@ -38,11 +39,12 @@
|
|||
:data-lname='prof.lastName'
|
||||
:data-fname='prof.firstName'>
|
||||
|
||||
<div class='remove' :data-remove='prof.idProfesseur' @click="gstore.ir_handler($event.currentTarget.getAttribute('data-remove'))"></div>
|
||||
<div class='edit' :data-edit='prof.idProfesseur' @click="gstore.ie_handler($event.currentTarget.getAttribute('data-edit'))"></div>
|
||||
<div class='remove' :data-remove='prof.idProfesseur' @click="gstore.ir_handler($event.currentTarget.getAttribute('data-remove'))"></div>
|
||||
<div class='edit' :data-edit='prof.idProfesseur' @click="gstore.ie_handler($event.currentTarget.getAttribute('data-edit'))"></div>
|
||||
<div class='admin' :data-admin='prof.idProfesseur' :data-active='prof.admin' @click="gstore.ia_handler($event.currentTarget.getAttribute('data-admin'))"></div>
|
||||
|
||||
<span class='category'>{{ prof.categorie }}</span>
|
||||
<h1 :class="prof.hoursToDo > prof.equiTD ? 'warning' : ''">{{ prof.firstName }} {{ prof.lastName }}</h1>
|
||||
<h1 :class="prof.hoursToDo > prof.equiTD ? 'warning' : ''">{{ prof.firstName }} {{ prof.lastName }} <span :data-visible='prof.casLogin.length'>{{ prof.casLogin }}</span></h1>
|
||||
|
||||
<div class='table'>
|
||||
<div>
|
||||
|
|
|
@ -207,7 +207,109 @@ gstore.add('is_handler', function(e){
|
|||
|
||||
|
||||
|
||||
/* (5) Manage instant remove
|
||||
/* (5) Manage instant create
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Initialize inputs */
|
||||
gstore.add('create_cat', '-');
|
||||
gstore.add('create_name', '');
|
||||
gstore.add('create_cas', '');
|
||||
gstore.add('create_h', '');
|
||||
|
||||
/* (2) Initialize error message */
|
||||
gstore.add('create_err', '');
|
||||
|
||||
/* (3) Define create handler */
|
||||
gstore.add('ic_handler', function(prof_id){
|
||||
|
||||
/* (3.1) Trim text input */
|
||||
gstore.get.create_name = gstore.get.create_name.trim();
|
||||
gstore.get.create_cas = gstore.get.create_cas.trim().toLowerCase();
|
||||
gstore.get.create_h = gstore.get.create_h.trim();
|
||||
|
||||
/* (3.2) Store values locally */
|
||||
var cat = gstore.get.create_cat;
|
||||
var name = gstore.get.create_name.split(' ');
|
||||
var cas = gstore.get.create_cas;
|
||||
var hour = gstore.get.create_h;
|
||||
|
||||
console.log(cat, name, cas, hour);
|
||||
|
||||
/* (3.3) Init client-side check */
|
||||
var errors = [];
|
||||
|
||||
/* (3.3.1) Check category */
|
||||
if( isNaN(cat) ) errors.push('La catégorie de l\'enseignant est manquante');
|
||||
|
||||
/* (3.3.2) Check name */
|
||||
if( name.length !== 2 || name[0].length < 2 || name[1].length < 2 )
|
||||
errors.push('Le nom doit suivre le format "Prénom Nom"');
|
||||
|
||||
/* (3.3.3) Check CAS login */
|
||||
if( !/^([a-z]{4,16})?$/.test(cas) )
|
||||
errors.push('L\'identifiant doit être vide ou comprendre de 4 à 16 lettres');
|
||||
|
||||
/* (3.3.4) Check hours */
|
||||
if( hour === '' || isNaN(hour) || hour < 0 )
|
||||
errors.push('Le nombre d\'heures doit être un entier positif.');
|
||||
|
||||
/* (3.4) Show first error only (for 2s) */
|
||||
if( errors.length > 0 ){
|
||||
|
||||
gstore.get.create_err = errors[0];
|
||||
|
||||
return setTimeout(() => gstore.add('create_err', ''), 2000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (4.1) Création de la requête */
|
||||
var rq = {
|
||||
firstName: name[1],
|
||||
lastName: name[0],
|
||||
category: cat,
|
||||
initials: name[1].substr(0,2)+name[0].substr(0,2),
|
||||
hoursToDo: hour,
|
||||
isAdmin: false
|
||||
};
|
||||
|
||||
// optional cas_login
|
||||
if( cas.length > 0 ) rq.casLogin = cas;
|
||||
|
||||
|
||||
/* (4.2) Send request */
|
||||
api.call('POST professor', rq, function(rs){
|
||||
|
||||
console.log(rs);
|
||||
|
||||
/* (4.2.1) Manage 'already exist' error */
|
||||
if( rs.error == 29 ){
|
||||
gstore.get.create_err = 'Le couple Nom-Prénom est déja utilisé.';
|
||||
return setTimeout(() => gstore.add('create_err', ''), 2000);
|
||||
}
|
||||
|
||||
/* (4.2.2) Manage other errors */
|
||||
if( rs.error !== 0 ){
|
||||
gstore.get.create_err = 'erreur ('+rs.error+') Impossible de créer l\'enseignant';
|
||||
return setTimeout(() => gstore.add('create_err', ''), 2000);
|
||||
}
|
||||
|
||||
/* (4.2.3) Show that user is created */
|
||||
console.log('Create')
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* (6) Manage instant remove
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Define remove handler */
|
||||
gstore.add('ir_handler', function(prof_id){
|
||||
|
@ -277,7 +379,7 @@ gstore.add('ir_handler', function(prof_id){
|
|||
|
||||
|
||||
|
||||
/* (6) Manage instant edit
|
||||
/* (7) Manage instant edit
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Define edit handler */
|
||||
gstore.add('ie_handler', function(prof_id){
|
||||
|
|
|
@ -168,9 +168,10 @@
|
|||
&.filter-hidden{ display: none; }
|
||||
|
||||
|
||||
/* (2) REMOVE+EDIT button */
|
||||
/* (2) REMOVE+EDIT+ADMIN button */
|
||||
& > div.remove[data-remove],
|
||||
& > div.edit[data-edit]{
|
||||
& > div.edit[data-edit],
|
||||
& > div.admin[data-admin]{
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
top: 1.3em;
|
||||
|
@ -189,7 +190,7 @@
|
|||
|
||||
}
|
||||
|
||||
/* (3) EDIT button */
|
||||
/* (2.1) EDIT button */
|
||||
& > div.edit[data-edit]{
|
||||
left: calc( 100% - 2em - 1.3em );
|
||||
|
||||
|
@ -202,13 +203,26 @@
|
|||
|
||||
}
|
||||
|
||||
/* (2.2) ADMIN switch */
|
||||
& > div.admin[data-admin]{
|
||||
left: calc( 100% - 2em - 1.3em - 1.3em );
|
||||
|
||||
background-image: url('/asset/svg/admin.svg@bbbbbb');
|
||||
background-size: 85% auto;
|
||||
|
||||
&:hover{ background-image: url('/asset/svg/admin.svg@bbbbbb'); }
|
||||
|
||||
&[data-active='1']{ background-image: url('/asset/svg/admin.svg@f4bd18'); }
|
||||
|
||||
}
|
||||
|
||||
/* (4) Card generic title */
|
||||
& > span.category,
|
||||
& > select.category{
|
||||
|
||||
display: block;
|
||||
position: relative;
|
||||
width: calc( 100% - 3em );
|
||||
width: calc( 100% - 5em );
|
||||
|
||||
margin-bottom: .5em;
|
||||
|
||||
|
@ -222,6 +236,7 @@
|
|||
/* (4-edit) Card generic title (select) */
|
||||
& > select.category{
|
||||
|
||||
width: calc( 100% + 1em );
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-left: -.4em; // emulate no <select>
|
||||
|
@ -273,7 +288,7 @@
|
|||
}
|
||||
|
||||
/* (5-edit) Card title -> edit inputs */
|
||||
input{
|
||||
& input{
|
||||
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
|
@ -295,6 +310,29 @@
|
|||
background: transparent;
|
||||
}
|
||||
|
||||
/* (5.1) Sub-content */
|
||||
& > span[data-visible]{
|
||||
|
||||
display: inline-block;
|
||||
color: $secondary-color;
|
||||
|
||||
margin: 0;
|
||||
margin-left: .5em;
|
||||
|
||||
transform: scale(.9);
|
||||
|
||||
&:before{ content: '('; }
|
||||
&:after{ content: ')'; }
|
||||
|
||||
&[data-visible='0']{ display: none; }
|
||||
|
||||
/* (5.1-edit) input*/
|
||||
& > input{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (6) Card 2-column array */
|
||||
|
@ -487,6 +525,32 @@
|
|||
|
||||
color: lighten($primary-color, 20%);
|
||||
|
||||
&:before{
|
||||
content: '';
|
||||
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width: 0em;
|
||||
height: 1em;
|
||||
|
||||
background: center bottom -.1em no-repeat;
|
||||
background-size: auto .9em;
|
||||
|
||||
text-anchor: center;
|
||||
}
|
||||
|
||||
&.warning{
|
||||
|
||||
color: $form-invalid-color;
|
||||
|
||||
&:before{
|
||||
width: 1em;
|
||||
margin-right: .3em;
|
||||
background-image: url('/asset/svg/warning_radio.svg@#{$rd-form-invalid-color}');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue