Commit 5cafe37e authored by Lucas Détré's avatar Lucas Détré

enabling user/password authentification and url changing when accessing modification list

parent 9b51ed57
......@@ -60,22 +60,20 @@
windowLocationHash: decodeURI(window.location.hash),
rerenderKey: 0,
collapsed: false,
currentRuleName: decodeURI(window.location.hash).split('#').pop() == "modified" ? decodeURI(window.location.hash).split('#')[1]:decodeURI(window.location.hash).split('#').pop(),
}
},
computed: {
show: function () {
return (this.windowLocationHash !== '')
return (this.currentRuleName !== '')
},
currentRuleContent: function() {
this.forceRerender();
if(this.windowLocationHash !== '') return this.rules[this.currentRuleName]['data'];
if(this.currentRuleName !== '') return this.rules[this.currentRuleName]['data'];
else return null;
},
currentRuleName: function () {
return this.windowLocationHash.split('#').pop();
},
currentRuleFilePath: function () {
if(this.windowLocationHash !== '') return this.rules[this.currentRuleName]['path'];
if(this.currentRuleName !== '') return this.rules[this.currentRuleName]['path'];
else return null;
},
printRulePath: function () {
......@@ -83,11 +81,11 @@
var printpath = "(";
if(this.windowLocationHash.split('#').length -1 > 1) {
for(var i=1; i <= this.windowLocationHash.split('#').length -1; i++) {
if (this.windowLocationHash.split('#').pop() == 'modified') return "";
path += "#"+ this.windowLocationHash.split('#')[i];
if (i == this.windowLocationHash.split('#').length - 1) printpath += "<a href='"+ path + "'>" + this.windowLocationHash.split('#')[i] + "</a>"
else printpath += "<a href='"+ path + "'>" + this.windowLocationHash.split('#')[i] + "</a> > ";
}
return printpath+")";
} return printpath+")";
} else return "";
},
rulePath: function () {
......@@ -114,6 +112,7 @@
this.loadRules();
window.addEventListener('popstate', () => {
this.windowLocationHash = decodeURI(window.location.hash);
this.currentRuleName = decodeURI(window.location.hash).split('#').pop() == "modified" ? decodeURI(window.location.hash).split('#')[1]:decodeURI(window.location.hash).split('#').pop();
})
},
methods: {
......
<template>
<div id="Rule">
<div class="mb-5">
<div class="row mb-3">
<div class="col-md-6 col-sm-12 col-xs-12">
<h5>
<span style="vertical-align:-30%" >{{ displayedName }}</span>
</h5>
<span v-if="this.modification_count" @click="displayModification()" id="modification_link">({{ this.modification_count }} modification<span v-if="this.modification_count > 1">s</span> en cours)</span>
<div v-if="!isLoading">
<div class="mb-5">
<div class="row mb-3">
<div class="col-md-6 col-sm-12 col-xs-12">
<h5>
<span style="vertical-align:-30%" >{{ displayedName }}</span>
</h5>
<a :href="'#'+name+'#modified'" v-if="this.modification_count" @click="displayModification()" id="modification_link">({{ this.modification_count }} modification<span v-if="this.modification_count > 1">s</span> en cours)</a>
</div>
<div class="col-md-6 col-sm-12 col-xs-12">
<h4 v-if="isEditMode" class="pull-right"><em>Modification de la règle</em></h4>
<input v-else v-b-modal.auth-modal type="button" class="main-button btn pull-right" value="Soumettre une modification"/>
<!-- TODO: show gitlab link of modification if exists -->
</div>
</div>
<div class="col-md-6 col-sm-12 col-xs-12">
<h4 v-if="isEditMode" class="pull-right"><em>Modification de la règle</em></h4>
<input v-else v-b-modal.auth-modal type="button" class="main-button btn pull-right" value="Soumettre une modification"/>
<!-- TODO: show gitlab link of modification if exists -->
<div v-show="!isEditMode" class="row">
<div class="col-md-12">
<span v-html="printRulePath"></span>
</div>
</div>
</div>
<div v-show="!isEditMode" class="row">
<div class="col-md-12">
<span v-html="printRulePath"></span>
</div>
<div v-if="viewModification">
<ul v-for="modification in modification_list" :key="modification.id">
<Modification :modification="modification"/>
</ul>
</div>
</div>
<div v-if="viewModification">
<ul v-for="modification in modification_list" :key="modification.id">
<Modification :modification="modification"/>
</ul>
</div>
<div v-show="!isEditMode && !viewModification">
<ul>
<TreeItem class="item" :item="this.ruleTree" :rootElement="true" :rulePath="this.rulePath"></TreeItem>
</ul>
</div>
<div v-show="isEditMode">
<div class="row mb-3">
<div class="col-md-6 pl-0">
<input @click="closeEdit" type="button" class="btn btn-outline-danger pull-left" value="Annuler"/>
</div>
<div class="col-md-6 pr-0">
<button v-b-modal.mail-modal class="btn btn-outline-success pull-right">Enregistrer</button>
</div>
<div v-show="!isEditMode && !viewModification">
<ul>
<TreeItem class="item" :item="this.ruleTree" :rootElement="true" :rulePath="this.rulePath"></TreeItem>
</ul>
</div>
<div class="container">
<div class="row mb-3">
<label for="content"><u>Contenu de la règle</u></label>
<textarea-autosize id="content" v-model="content" class="rule-modification-text" :class="{editErrorClass: notModified}"></textarea-autosize>
<span v-if="notModified" class="text-danger font-weight-light">Aucune modification n'a été renseignée</span>
</div>
<div v-show="isEditMode">
<div class="row mb-3">
<div class="col-md-6 pl-0">
<input @click="closeEdit" type="button" class="btn btn-outline-danger pull-left" value="Annuler"/>
......@@ -54,16 +40,30 @@
<button v-b-modal.mail-modal class="btn btn-outline-success pull-right">Enregistrer</button>
</div>
</div>
<div class="container">
<div class="row mb-3">
<label for="content"><u>Contenu de la règle</u></label>