add frontend frame and service logic

This commit is contained in:
2021-07-03 00:41:03 -05:00
parent 87312fbc86
commit be789ae882
49 changed files with 10019 additions and 65 deletions

View File

@ -0,0 +1,66 @@
<template>
<div class="{{component}}-editor">
<div class="input-row">
<label>Grant Name: </label>
<input class="form-control" type="text" ref="name" placeholder="Grant Name" v-model="grant.name" />
</div>
<!-- SYSTEM-BUILDER-input-row -->
<div class="errorMessage" v-if="errorMessage != ''">{{errorMessage}}</div>
<div class="action-buttons">
<button class="btn" @click="close()">Cancel</button>
<button class="btn btn-secondary" :disabled="!isComplete" @click="isComplete && save{{Component}}()">Save</button>
</div>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { {{component}}Service } from './{{component}}Service.ts';
import { {{Component}}Config } from './{{component}}Types.ts';
@Component
export default class {{Component}}Editor extends Vue {
@Prop() private {{component}}!: {{Component}}Config;
private loading: boolean = false;
private errorMessage: string = '';
get isComplete() {
return true;
}
private save{{Component}}() {
this.loading = true;
this.errorMessage = '';
// either create or update...
if (this.{{component}}.id === '') { // TODO: use the primary key instead of 'id' here
{{component}}Service.create{{Component}}(this.{{component}}).then(() => {
// success
this.loading = false;
this.errorMessage = '';
this.close();
}).catch(this.handleError.bind(this));
} else {
{{component}}Service.update{{Component}}(this.{{component}}).then(() => {
// success
this.loading = false;
this.errorMessage = '';
this.close();
}).catch(this.handleError.bind(this));
}
}
private handleError(err: any) {
// error
this.loading = false;
this.errorMessage = err.message;
}
}
</script>
<style scoped lang="css">
.errorMessage {
color: red;
}
</style>