createprojectgroup: add loading indicator and enabled to button
This commit is contained in:
parent
b3c22f8429
commit
e783958100
@ -13,7 +13,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button class="button is-primary" @click="createProjectGroup()">Create Project Group</button>
|
<button
|
||||||
|
class="button is-primary"
|
||||||
|
v-bind:class="{ 'is-loading': createProjectGroupLoading }"
|
||||||
|
:disabled="!createProjectGroupButtonEnabled"
|
||||||
|
@click="createProjectGroup()"
|
||||||
|
>Create Project Group</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="createProjectGroupError" class="message is-danger">
|
<div v-if="createProjectGroupError" class="message is-danger">
|
||||||
@ -38,13 +43,29 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
createProjectGroupError: null,
|
createProjectGroupError: null,
|
||||||
projectGroupName: null
|
createProjectGroupLoading: false,
|
||||||
|
createProjectGroupLoadingTimeout: null,
|
||||||
|
projectGroupName: ""
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
createProjectGroupButtonEnabled: function() {
|
||||||
|
return this.projectGroupName.length;
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resetErrors() {
|
resetErrors() {
|
||||||
this.createProjectGroupError = null;
|
this.createProjectGroupError = null;
|
||||||
},
|
},
|
||||||
|
startProjectGroupLoading() {
|
||||||
|
this.createProjectGroupLoadingTimeout = setTimeout(() => {
|
||||||
|
this.createProjectGroupLoading = true;
|
||||||
|
}, 300);
|
||||||
|
},
|
||||||
|
stopProjectGroupLoading() {
|
||||||
|
clearTimeout(this.createProjectGroupLoadingTimeout);
|
||||||
|
this.createProjectGroupLoading = false;
|
||||||
|
},
|
||||||
async createProjectGroup() {
|
async createProjectGroup() {
|
||||||
this.resetErrors();
|
this.resetErrors();
|
||||||
|
|
||||||
@ -54,10 +75,12 @@ export default {
|
|||||||
}
|
}
|
||||||
let parentref = refArray.join("/");
|
let parentref = refArray.join("/");
|
||||||
|
|
||||||
|
this.startProjectGroupLoading();
|
||||||
let { error } = await createProjectGroup(
|
let { error } = await createProjectGroup(
|
||||||
parentref,
|
parentref,
|
||||||
this.projectGroupName
|
this.projectGroupName
|
||||||
);
|
);
|
||||||
|
this.stopProjectGroupLoading();
|
||||||
if (error) {
|
if (error) {
|
||||||
this.createProjectGroupError = error;
|
this.createProjectGroupError = error;
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user