Commit 83a7ce99 authored by Johannes Winter's avatar Johannes Winter

repaired start with no saved budgets

added enter key event listeners for modals and default foci
forbid the deletion of the current dataset
decoded display of the IRI of the current dataset
parent 4490e211
<template>
<b-field label="Set associated process to: ">
<b-field label="Set associated activity to: ">
<b-select v-model="selectedProcess" @input="$emit('input',$event)">
<option
v-for="process in procs"
......
<template>
<div class="modal-card" style="width: auto">
<div class="modal-card" style="width: auto" @keyup.enter.capture="saveIntent()">
<header class="modal-card-head">
<p class="modal-card-title">Add expense</p>
</header>
<section class="modal-card-body">
<b-field label="Name">
<b-input v-model="intentName" placeholder='Enter Name of expense'></b-input>
<b-field label="Name" >
<b-input v-model="intentName"
placeholder="Enter Name of expense"
ref="nameField">
</b-input>
</b-field>
<b-field label="Amount">
<b-input v-model.number="intentValue"></b-input>
<b-input v-model.number="intentValue" @keyup.enter="saveIntent()"></b-input>
</b-field>
<ProcessSelector :currentProc="this.focus.ID" @input="newParentProcess($event)"/>
<b-field label="Include in expense">
......@@ -54,6 +57,9 @@ export default {
ProcessSelector,
IntentSelector
},
mounted() {
this.$refs.nameField.focus()
},
methods: {
newParentProcess: function(proc) {
this.returnProcess=proc
......
<template>
<div class="modal-card" style="width: auto">
<div class="modal-card" style="width: auto" @keyup.enter.capture="saveProcess()">
<header class="modal-card-head">
<p class="modal-card-title">Add activity</p>
</header>
<section class="modal-card-body">
<b-field label="Name">
<b-input v-model="lowerProcessName" placeholder='Enter activity name'></b-input>
<b-input v-model="lowerProcessName"
placeholder='Enter activity name'
ref="nameField">
</b-input>
</b-field>
<ProcessSelector :currentProc="this.focus.ID" @input="newParentProcess($event)"/>
</section>
......@@ -42,6 +45,9 @@ export default {
components: {
ProcessSelector
},
mounted() {
this.$refs.nameField.focus()
},
methods: {
newParentProcess: function(proc) {
this.higherProcessId=proc
......
<template>
<div class="modal-card" style="width: auto">
<div class="modal-card" style="width: auto" @keyup.enter.capture="save()">
<header class="modal-card-head">
<p class="modal-card-title">Edit properties of {{this.type == 'process' ? 'activity' : 'expense'}} {{this.label}}.</p>
</header>
......
......@@ -29,7 +29,7 @@
</span>
<span>Delete</span>
</button>
<button class="button is-warning is-rounded" @click="resetBudget()()">
<button class="button is-warning is-rounded" @click="resetBudget()">
<span class="icon is-small">
<i class="fas fa-times"></i>
</span>
......@@ -97,6 +97,16 @@ export default {
)
},
deleteBudget() {
// don't allow to delete the current dataset
if (this.$store.getters.ldRessource==this.selectedBudgetUrl) {
this.$toast.open({
message: 'You are not allowed to delete your own data foundation.',
type: 'is-danger',
duration: 3000
})
this.$parent.close()
return false
}
this.$dialog.confirm({
message: 'Do you really want to delete Budget <i>'+ this.selectedBudget + '</i> ?',
onConfirm: () => {
......@@ -137,30 +147,31 @@ export default {
this.$toast.open(`Please login first!`)
return false
}
this.$store.dispatch('initGraph')
this.$store.dispatch('initGraph').then(()=>{
this.$store.commit('addProcess', {name: 'farming', ID: farmId})
this.$store.commit('addProcess', {name: 'farming', ID: farmId})
this.$store.commit('createIntent', {name: 'farmland', value: 30, ID: farmlandId})
this.$store.dispatch('addIntentId', {intentId: farmlandId.value, processId: farmId.value })
this.$store.commit('createIntent', {name: 'farmland', value: 30, ID: farmlandId})
this.$store.dispatch('addIntentId', {intentId: farmlandId.value, processId: farmId.value })
this.$store.commit('createIntent', {name: 'farmwork', value: 10, ID: farmworkId })
this.$store.dispatch('addIntentId', {intentId: farmworkId.value, processId: farmId.value })
this.$store.commit('createIntent', {name: 'farmwork', value: 10, ID: farmworkId })
this.$store.dispatch('addIntentId', {intentId: farmworkId.value, processId: farmId.value })
this.$store.commit('addProcess', {name: 'market garden' , ID: gardenId})
this.$store.commit('createIntent', {name: 'gardenland', value: 20, ID: gardenlandId})
this.$store.dispatch('addIntentId', { intentId: gardenlandId.value, processId: gardenId.value })
this.$store.commit('addProcess', {name: 'market garden' , ID: gardenId})
this.$store.commit('createIntent', {name: 'gardenland', value: 20, ID: gardenlandId})
this.$store.dispatch('addIntentId', { intentId: gardenlandId.value, processId: gardenId.value })
this.$store.commit('createIntent', {name: 'gardenwork', value: 10, ID: gardenworkId})
this.$store.dispatch('addIntentId', {intentId: gardenworkId.value, processId: gardenId.value })
this.$store.commit('createIntent', {name: 'gardenwork', value: 10, ID: gardenworkId})
this.$store.dispatch('addIntentId', {intentId: gardenworkId.value, processId: gardenId.value })
this.$store.commit('addProcess', {name: 'CSA', value: 0 , ID: CSAId})
this.$store.dispatch('addRelation', {higher: CSAId.value,lower: farmId.value})
this.$store.dispatch('addRelation', {higher: CSAId.value,lower: gardenId.value})
this.$store.commit('addProcess', {name: 'CSA', value: 0 , ID: CSAId})
this.$store.dispatch('addRelation', {higher: CSAId.value,lower: farmId.value})
this.$store.dispatch('addRelation', {higher: CSAId.value,lower: gardenId.value})
console.log('Loaded hard coded sample data graph:\n' + this.$store.state.graph);
this.$emit('repaintChart')
this.$parent.close()
console.log('Loaded hard coded sample data graph:\n' + this.$store.state.graph);
this.$emit('repaintChart', CSAId.value)
this.$parent.close()
})
}
},
mounted() {
......
<template>
<div class="modal-card" style="width: auto">
<div class="modal-card" style="width: auto" @keyup.enter.capture="save">
<header class="modal-card-head">
<p class="modal-card-title">Save Budget</p>
</header>
<section class="modal-card-body">
<b-field label="Name">
<b-input v-model="ressourceName" placeholder='Edit ressource name'></b-input>
<b-input v-model="ressourceName"
placeholder='Edit ressource name'
ref="nameField">
</b-input>
</b-field>
</section>
<footer class="modal-card-foot">
<button class="button is-small is-dark" @click="save()">Save!</button>
<footer class="modal-card-foot" style="justify-content:space-between">
<button class="button is-success is-rounded" @click="save()">
<span class="icon is-small">
<i class="fas fa-check"></i>
</span>
<span>Save</span>
</button>
<button class="button is-warning is-rounded" @click="$parent.close()">
<span class="icon is-small">
<i class="fas fa-times"></i>
</span>
<span>Cancel</span>
</button>
</footer>
</div>
</template>
......@@ -21,7 +35,7 @@ export default {
name: 'saveModal',
data: function () {
return {
ressourceName: this.$store.getters.ldRessourceName,
ressourceName: decodeURIComponent(this.$store.getters.ldRessourceName),
}
},
computed: {
......@@ -32,6 +46,9 @@ export default {
return loc.href
}
},
mounted() {
this.$refs.nameField.focus()
},
methods: {
save() {
this.$store.commit('setLdRessource', this.selectedBudgetUrl)
......
......@@ -196,12 +196,12 @@ export default new Vuex.Store({
return state.graph.any(undefined, VFBT('estimatedDemand'), ID)
},
iniName: state => {
iniName: state => { // TODO: check why it doesn't work without log commands
var st
//console.log('iniName graph:\n' + state.graph);
console.log('iniName graph:\n' + state.graph);
if (state.webId == "") return ''
st = state.graph.any($rdf.sym(state.webId), VFBT('name'))
//console.log('iniName st:\n' + st);
// console.log('iniName st:\n' + st);
if (st != undefined) return st.value
else return ''
},
......@@ -279,7 +279,7 @@ export default new Vuex.Store({
var processId= new $rdf.BlankNode()
ID.value=processId
if (ID != undefined ) ID.value=processId
sts.push(new $rdf.Statement(processId,RDF('type'),VFBT('Process')))
sts.push(new $rdf.Statement(processId,VFBT('name'),name))
state.graph.addAll(sts)
......@@ -647,21 +647,28 @@ export default new Vuex.Store({
})
},
initGraph ({state, getters}) {
var sts = []
state.graph=$rdf.graph()
console.log('initGraph:');
console.log(state.webId);
sts.push(new $rdf.Statement($rdf.sym(state.webId), RDF('type'),ESSGLOBAL('SSEInitiative')))
sts.push(new $rdf.Statement($rdf.sym(state.webId), VFBT('name'), 'Solawi XYZ'))
sts.push(new $rdf.Statement($rdf.sym(state.webId), ESSGLOBAL('totalOfMembers'), 171))
sts.push(new $rdf.Statement(getters.budgetNs('budget'), RDF('type'), VFBT('Budget')))
sts.push(new $rdf.Statement(getters.budgetNs('budget'), VFBT('preparedFor'),$rdf.sym(state.webId)))
sts.push(new $rdf.Statement(getters.budgetNs('budget'), VFBT('budgetUnit'), 'Euro'))
sts.push(new $rdf.Statement(getters.budgetNs('budget'), DC('valid'), '2019'))
state.graph.addAll(sts)
return new Promise((resolve, reject) => {
setTimeout(() => {
var sts = []
state.graph=$rdf.graph()
console.log('initGraph:');
console.log(state.webId);
sts.push(new $rdf.Statement($rdf.sym(state.webId), RDF('type'),ESSGLOBAL('SSEInitiative')))
sts.push(new $rdf.Statement($rdf.sym(state.webId), VFBT('name'), 'Solawi XYZ'))
sts.push(new $rdf.Statement($rdf.sym(state.webId), ESSGLOBAL('totalOfMembers'), 171))
sts.push(new $rdf.Statement(getters.budgetNs('budget'), RDF('type'), VFBT('Budget')))
sts.push(new $rdf.Statement(getters.budgetNs('budget'), VFBT('preparedFor'),$rdf.sym(state.webId)))
sts.push(new $rdf.Statement(getters.budgetNs('budget'), VFBT('budgetUnit'), 'Euro'))
sts.push(new $rdf.Statement(getters.budgetNs('budget'), DC('valid'), '2019'))
state.graph.addAll(sts)
console.log('init graph:');
console.log(JSON.stringify(state.graph));
resolve()
},1000
)})
},
loadBudget( {commit, state}, iri) {
return new Promise((resolve, reject) => {
......@@ -764,8 +771,12 @@ export default new Vuex.Store({
}
state.budgetList=graph.each(new $rdf.sym(loc.href),LDP('contains'))
console.log('saved Budgets:\n' + state.budgetList);
resolve()
if (state.budgetList.length==0) {
reject('nothing saved')
} else {
console.log('saved Budgets:\n' + state.budgetList);
resolve()
}
})
}
)},1000)
......
......@@ -17,7 +17,7 @@
<b>{{focus.name}}</b> sums up to {{ this.budget_size }} {{ this.$store.getters.currency }} for {{ this.numberOfMembers }} members.<br>
This is an average of {{ Math.round(this.budget_size / this.numberOfMembers) }} {{ this.$store.getters.currency }} per member.<br>
</diV>
<div v-else-if="processes.ascendants">
<div v-else-if="processes.ascendants && processes.ascendants.length>0">
<b>{{focus.name}}</b> contributes to <a @click="fillData(processes.ascendants[0].ID)">{{processes.ascendants[0].name}}</a> by {{Math.round((focus.value/processes.ascendants[0].value)*100)}}%
</div>
......@@ -30,7 +30,7 @@
</div>
<ControlField @repaintChart="fillData($event)" :focus="this.focus"/>
<hr>
Saved on: <a :href="this.$store.getters.ldRessource">{{this.$store.getters.ldRessource}}</a>
Saved on: <a :href="this.$store.getters.ldRessource">{{decodeURIComponent(this.$store.getters.ldRessource)}}</a>
</div>
</div>
<b-modal :active.sync="isEditModalActive" has-modal-card>
......@@ -39,6 +39,9 @@
:ID="focus.ID"
@valueChanged="fillData()"/>
</b-modal>
<b-modal :active.sync="isProcessModalActive" has-modal-card>
<addProcessModal :focus="this.focus" @repaintChart="$emit('repaintChart',$event)"></addProcessModal>
</b-modal>
</div>
</template>
......@@ -71,7 +74,8 @@
returnName: '',
focus: [],
loggedIn: false,
isEditModalActive: false
isEditModalActive: false,
isProcessModalActive: false
}
},
mounted () {
......@@ -86,6 +90,16 @@
if (failure == 401) {
auth.logout()
this.$router.push('config')
} else if (failure=='nothing saved') { // start from scratch. Set initial process name to webId Name
this.$store.dispatch('initGraph').then(()=> {
var iniName=this.$store.getters.iniName
var ID={}
console.log('start from scratch');
console.log(this.$store.state.webId);
console.log(iniName);
this.$store.commit('addProcess', {name: iniName, ID: ID})
this.fillData(ID.value)
})
}
console.log(failure)
})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment