add frontend frame and service logic
This commit is contained in:
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<div class="{{component}}-editor">
|
||||
<div class="property-row">
|
||||
<label>Grant Name: </label>
|
||||
<div>grant.name</div>
|
||||
</div>
|
||||
|
||||
<!-- SYSTEM-BUILDER-property-row -->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
import { {{Component}}Config } from './{{component}}Types.ts';
|
||||
|
||||
@Component
|
||||
export default class {{Component}}Editor extends Vue {
|
||||
@Prop() private {{component}}!: {{Component}}Config;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="css">
|
||||
.errorMessage {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
@ -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>
|
@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div class="{{component}}-editor">
|
||||
<div>TODO: search</div>
|
||||
|
||||
<div v-for="item in items" :key="item.id" class="input-row">
|
||||
<div class="">{{ item.id }}</div>
|
||||
</div>
|
||||
|
||||
<div class="errorMessage" v-if="errorMessage != ''">{{errorMessage}}</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 {
|
||||
private items!: {{Component}}Config[];
|
||||
private loading: boolean = false;
|
||||
private errorMessage: string = '';
|
||||
// SYSTEM-BUILDER-component-variables
|
||||
|
||||
// SYSTEM-BUILDER-component-functions
|
||||
|
||||
private get{{Component}}s() {
|
||||
this.loading = true;
|
||||
this.errorMessage = '';
|
||||
{{component}}Service.get{{Component}}s().then((listItems: {{Component}}Config[]) => {
|
||||
// success
|
||||
this.loading = false;
|
||||
this.errorMessage = '';
|
||||
this.items = listItems;
|
||||
}).catch(this.handleError.bind(this));
|
||||
}
|
||||
|
||||
// TODO: add a search function if there is an endpoint with type 'search'
|
||||
|
||||
private handleError(err: any) {
|
||||
// error
|
||||
this.loading = false;
|
||||
this.errorMessage = err.message;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="css">
|
||||
.errorMessage {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,13 @@
|
||||
import { del, get, post, put } from '@/services/fetch';
|
||||
|
||||
class {{Component}}Service {
|
||||
// SYSTEM-BUILDER-service-variables
|
||||
// SYSTEM-BUILDER-service-functions
|
||||
}
|
||||
|
||||
let {{component}}Service = new {{Component}}Service();
|
||||
|
||||
export {
|
||||
{{component}}Service,
|
||||
{{Component}}Service
|
||||
};
|
@ -0,0 +1,10 @@
|
||||
|
||||
// SYSTEM-BUILDER-{{component}}-interfaces
|
||||
|
||||
// e.g.
|
||||
// interface {{Component}}Config {
|
||||
// }
|
||||
|
||||
export {
|
||||
// SYSTEM-BUILDER-{{component}}-exports
|
||||
};
|
Reference in New Issue
Block a user