-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStandardComponentForm.ts
62 lines (55 loc) · 1.81 KB
/
StandardComponentForm.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* This file is part of the Klipper package.
*
* (c) François Pluchino <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import {AjaxFormContent} from '@klipper/bow/mixins/http/AjaxFormContent';
import {StandardBaseComponent} from '@klipper/bow/mixins/StandardBaseComponent';
import {createStandardViewData, StandardViewData} from '@klipper/bow/standardView/StandardViewData';
import {mixins} from 'vue-class-component';
import {Component, Watch} from 'vue-property-decorator';
/**
* @author François Pluchino <[email protected]>
*/
@Component
export class StandardComponentForm extends mixins(
StandardBaseComponent,
AjaxFormContent,
) {
protected get pushLoading(): boolean {
return this.loading && this.editMode;
}
protected get isFormDisabled(): boolean {
return this.formDisabled || this.loading;
}
protected get genStandardData(): StandardViewData {
return createStandardViewData({
metadata: this.metadataName || null,
currentLocale: this.currentLocale,
editMode: this.editMode,
vertical: this.isVertical,
dense: this.isDense,
loading: this.loading,
showLoading: false,
isCreate: this.isCreate,
id: this.id || null,
data: this.data,
error: this.previousError,
pushAction: this.push,
});
}
public async push(): Promise<void> {
// Override this method
}
protected beforeCancelEdit(): void {
this.resetPreviousError();
}
@Watch('loading')
@Watch('previousError')
protected watchAjaxStandardDataValues(): void {
this.watchStandardDataValues();
}
}