-
Notifications
You must be signed in to change notification settings - Fork 0
/
unresolved-other-info.ts
100 lines (91 loc) · 3.37 KB
/
unresolved-other-info.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import {sharedStyles} from '@unicef-polymer/etools-modules-common/dist/styles/shared-styles-lit';
import '@unicef-polymer/etools-unicef/src/etools-content-panel/etools-content-panel';
import {html, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';
import {translate, get as getTranslation} from 'lit-translate';
import ComponentBaseMixin from '@unicef-polymer/etools-modules-common/dist/mixins/component-base-mixin';
import {layoutStyles} from '@unicef-polymer/etools-unicef/src/styles/layout-styles';
import {getStore} from '@unicef-polymer/etools-utils/dist/store.util';
import {AsyncAction} from '@unicef-polymer/etools-types';
import {openDialog} from '@unicef-polymer/etools-utils/dist/dialog.util';
import {patchIntervention} from './common/actions/interventions';
import '@unicef-polymer/etools-unicef/src/etools-button/etools-button';
@customElement('unresolved-other-info-review')
export class UnresolvedOtherInfo extends ComponentBaseMixin(LitElement) {
static get styles() {
return [layoutStyles];
}
render() {
// language=HTML
return html`
${sharedStyles}
<style>
:host {
display: block;
margin-bottom: 24px;
}
etools-content-panel::part(ecp-header) {
background-color: var(--light-error-color);
}
etools-content-panel::part(ecp-content) {
padding: 8px 24px 16px 24px;
}
</style>
<etools-content-panel show-expand-btn panel-title=${translate('IMPORT_INFO')} comment-element="other-info">
<div slot="panel-btns">${this.renderEditBtn(this.editMode, this.editPermissions)}</div>
<div class="row"><div class="col-12">${translate('MAKE_SURE_OTHER_INFO')}</div></div>
<div class="row">
<div class="col-12">
<etools-textarea
id="otherInfo"
label="${translate('INFO')}"
always-float-label
placeholder="—"
readonly
.value="${this.data?.other_info}"
@value-changed="${({detail}: CustomEvent) => this.valueChanged(detail, 'other_info')}"
>
</etools-textarea>
</div>
</div>
${this.hideActionButtons(this.editMode, this.editPermissions)
? html``
: html` <div class="right-align padding-v">
<etools-button variant="neutral" @click="${this.cancel}">${translate('GENERAL.CANCEL')}</etools-button>
<etools-button variant="primary" @click="${this.areYouSure}"
>${translate('MARK_AS_RESOLVED')}</etools-button
>
</div>`}
</etools-content-panel>
`;
}
@property({type: Object})
data!: {other_info: string};
@property({type: Boolean})
editPermissions!: boolean;
cancel() {
this.editMode = false;
}
async areYouSure() {
const confirmed = await openDialog({
dialog: 'are-you-sure',
dialogData: {
content: getTranslation('IMPORT_INFO_WILL_BE_DELETED_AS_A_RESULT'),
confirmBtnText: translate('DELETE'),
cancelBtnText: translate('CANCEL')
}
}).then(({confirmed}) => {
return confirmed;
});
if (confirmed) {
this.saveUnresolved();
}
}
saveUnresolved() {
getStore()
.dispatch<AsyncAction>(patchIntervention({other_info: ''}))
.then(() => {
this.editMode = false;
});
}
}