@openremote/or-rules 1.8.0-snapshot.20250725120001 → 1.8.0-snapshot.20250725123024

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +30 -30
  2. package/custom-elements.json +13 -13
  3. package/dist/umd/index.bundle.js +4744 -4744
  4. package/dist/umd/index.bundle.js.map +1 -1
  5. package/lib/flow-viewer/components/confirmation-dialog.js +24 -61
  6. package/lib/flow-viewer/components/connection-container.js +1 -35
  7. package/lib/flow-viewer/components/connection-line.js +28 -117
  8. package/lib/flow-viewer/components/context-menu.js +45 -140
  9. package/lib/flow-viewer/components/editor-workspace.js +20 -282
  10. package/lib/flow-viewer/components/flow-editor.js +47 -160
  11. package/lib/flow-viewer/components/flow-node-socket.js +31 -146
  12. package/lib/flow-viewer/components/flow-node.js +29 -192
  13. package/lib/flow-viewer/components/internal-picker.js +54 -271
  14. package/lib/flow-viewer/components/node-menu-item.js +32 -132
  15. package/lib/flow-viewer/components/node-panel.js +60 -104
  16. package/lib/flow-viewer/components/notification-dialog.js +23 -55
  17. package/lib/flow-viewer/components/popup-modal.js +54 -113
  18. package/lib/flow-viewer/components/rule-browser.js +30 -119
  19. package/lib/flow-viewer/components/selectable-element.js +1 -71
  20. package/lib/flow-viewer/components/selection-box.js +15 -119
  21. package/lib/flow-viewer/components/top-bar.js +49 -116
  22. package/lib/flow-viewer/components/workspace-contextmenu-options.js +5 -128
  23. package/lib/flow-viewer/components/writable-dropdown.js +5 -51
  24. package/lib/flow-viewer/converters/node-converter.js +1 -10
  25. package/lib/flow-viewer/flow-viewer.js +1 -19
  26. package/lib/flow-viewer/models/camera.js +1 -2
  27. package/lib/flow-viewer/models/context-menu-button.js +1 -2
  28. package/lib/flow-viewer/models/light-node-collection.js +1 -2
  29. package/lib/flow-viewer/models/status.js +1 -8
  30. package/lib/flow-viewer/node-structure/copy.machine.js +1 -34
  31. package/lib/flow-viewer/node-structure/identity.assigner.js +1 -10
  32. package/lib/flow-viewer/node-structure/identity.dom.link.js +1 -4
  33. package/lib/flow-viewer/node-structure/index.js +1 -5
  34. package/lib/flow-viewer/node-structure/socket.type.matcher.js +1 -50
  35. package/lib/flow-viewer/node-structure/utils.js +1 -109
  36. package/lib/flow-viewer/services/copy-paste-manager.js +1 -59
  37. package/lib/flow-viewer/services/exporter.js +1 -67
  38. package/lib/flow-viewer/services/input.js +1 -80
  39. package/lib/flow-viewer/services/integration.js +1 -27
  40. package/lib/flow-viewer/services/modal.js +8 -29
  41. package/lib/flow-viewer/services/project.js +1 -222
  42. package/lib/flow-viewer/services/shortcuts.js +1 -63
  43. package/lib/flow-viewer/styles/editor-workspace-style.js +53 -55
  44. package/lib/flow-viewer/styles/flow-node-style.js +93 -95
  45. package/lib/flow-viewer/styles/picker-styles.js +29 -31
  46. package/lib/flow-viewer/utils.js +1 -49
  47. package/lib/index.js +56 -953
  48. package/lib/json-viewer/forms/or-rule-form-alarm.js +18 -91
  49. package/lib/json-viewer/forms/or-rule-form-email-message.js +12 -51
  50. package/lib/json-viewer/forms/or-rule-form-localized.js +43 -269
  51. package/lib/json-viewer/forms/or-rule-form-push-notification.js +63 -152
  52. package/lib/json-viewer/forms/or-rule-form-webhook.js +101 -296
  53. package/lib/json-viewer/modals/or-rule-alarm-modal.js +17 -173
  54. package/lib/json-viewer/modals/or-rule-notification-modal.js +11 -196
  55. package/lib/json-viewer/modals/or-rule-radial-modal.js +17 -142
  56. package/lib/json-viewer/modals/or-rule-webhook-modal.js +8 -78
  57. package/lib/json-viewer/or-rule-action-alarm.js +5 -97
  58. package/lib/json-viewer/or-rule-action-attribute.js +33 -235
  59. package/lib/json-viewer/or-rule-action-notification.js +56 -465
  60. package/lib/json-viewer/or-rule-action-webhook.js +18 -49
  61. package/lib/json-viewer/or-rule-asset-query.js +126 -849
  62. package/lib/json-viewer/or-rule-condition.js +29 -216
  63. package/lib/json-viewer/or-rule-json-viewer.js +34 -393
  64. package/lib/json-viewer/or-rule-then-otherwise.js +113 -609
  65. package/lib/json-viewer/or-rule-trigger-query.js +57 -227
  66. package/lib/json-viewer/or-rule-when.js +126 -343
  67. package/lib/or-rule-group-viewer.js +12 -106
  68. package/lib/or-rule-text-viewer.js +22 -133
  69. package/lib/or-rule-tree.js +57 -601
  70. package/lib/or-rule-validity.js +62 -373
  71. package/lib/or-rule-viewer.js +81 -361
  72. package/lib/style.js +64 -89
  73. package/package.json +11 -11
@@ -1,378 +1,67 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- /*
8
- * Copyright 2025, OpenRemote Inc.
9
- *
10
- * See the CONTRIBUTORS.txt file in the distribution for a
11
- * full listing of individual contributors.
12
- *
13
- * This program is free software: you can redistribute it and/or modify
14
- * it under the terms of the GNU Affero General Public License as
15
- * published by the Free Software Foundation, either version 3 of the
16
- * License, or (at your option) any later version.
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU Affero General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU Affero General Public License
24
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
- */
26
- import { html, LitElement } from "lit";
27
- import { customElement, property, query } from "lit/decorators.js";
28
- import { OrRulesRuleChangedEvent } from "./index";
29
- import "@openremote/or-mwc-components/or-mwc-input";
30
- import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
31
- import i18next from "i18next";
32
- import { translate } from "@openremote/or-translate";
33
- import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";
34
- import { RRule, Weekday } from 'rrule';
35
- import moment from "moment";
36
- let OrRuleValidity = class OrRuleValidity extends translate(i18next)(LitElement) {
37
- constructor() {
38
- super();
39
- }
40
- updated(changedProps) {
41
- super.updated(changedProps);
42
- if (changedProps.has("ruleset") && this.ruleset) {
43
- this._validity = this.ruleset.meta ? this.ruleset.meta["validity"] : undefined;
44
- if (this._validity && this._validity.recurrence) {
45
- this._rrule = RRule.fromString(this._validity.recurrence);
46
- }
47
- else {
48
- this._rrule = undefined;
49
- }
50
- }
51
- }
52
- getWeekDay(weekday) {
53
- switch (weekday) {
54
- case "MO":
55
- return RRule.MO;
56
- case "TU":
57
- return RRule.TU;
58
- case "WE":
59
- return RRule.WE;
60
- case "TH":
61
- return RRule.TH;
62
- case "FR":
63
- return RRule.FR;
64
- case "SA":
65
- return RRule.SA;
66
- case "SU":
67
- return RRule.SU;
68
- }
69
- }
70
- isAllDay() {
71
- return this._validity && moment(this._validity.start).hours() === 0 && moment(this._validity.start).minutes() === 0
72
- && moment(this._validity.end).hours() === 23 && moment(this._validity.end).minutes() === 59;
73
- }
74
- setRRuleValue(value, key) {
75
- let origOptions = this._rrule ? this._rrule.origOptions : undefined;
76
- const validity = this._validity;
77
- switch (key) {
78
- case "all-day":
79
- if (value) {
80
- validity.start = moment(validity.start).startOf("day").toDate().getTime();
81
- validity.end = moment(validity.end).endOf("day").toDate().getTime();
82
- }
83
- else {
84
- validity.start = moment().toDate().getTime();
85
- validity.end = moment().add(1, 'hour').toDate().getTime();
86
- }
87
- break;
88
- case "start":
89
- const newStartDate = moment(value);
90
- if (newStartDate.isValid()) {
91
- validity.start = newStartDate.set({ hour: 0, minute: 0, second: 0, millisecond: 0 }).toDate().getTime();
92
- if (this.getValidityType() === "validityRecurrence") {
93
- origOptions.dtstart = newStartDate.toDate();
94
- this._rrule = new RRule(origOptions);
1
+ var __decorate=this&&this.__decorate||function(t,e,i,a){var r,l=arguments.length,s=l<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,a);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(s=(l<3?r(s):l>3?r(e,i,s):r(e,i))||s);return l>3&&s&&Object.defineProperty(e,i,s),s};import{html as t,LitElement as e}from"lit";import{customElement as i,property as a,query as r}from"lit/decorators.js";import{OrRulesRuleChangedEvent as l}from"./index";import"@openremote/or-mwc-components/or-mwc-input";import{InputType as s}from"@openremote/or-mwc-components/or-mwc-input";import o from"i18next";import{translate as n}from"@openremote/or-translate";import{OrMwcDialog as d,showDialog as u}from"@openremote/or-mwc-components/or-mwc-dialog";import{RRule as y,Weekday as c}from"rrule";import m from"moment";let OrRuleValidity=class extends n(o)(e){constructor(){super()}updated(t){super.updated(t),t.has("ruleset")&&this.ruleset&&(this._validity=this.ruleset.meta?this.ruleset.meta.validity:void 0,this._validity&&this._validity.recurrence?this._rrule=y.fromString(this._validity.recurrence):this._rrule=void 0)}getWeekDay(t){switch(t){case"MO":return y.MO;case"TU":return y.TU;case"WE":return y.WE;case"TH":return y.TH;case"FR":return y.FR;case"SA":return y.SA;case"SU":return y.SU}}isAllDay(){return this._validity&&0===m(this._validity.start).hours()&&0===m(this._validity.start).minutes()&&23===m(this._validity.end).hours()&&59===m(this._validity.end).minutes()}setRRuleValue(t,e){let i=this._rrule?this._rrule.origOptions:void 0,a=this._validity;switch(e){case"all-day":t?(a.start=m(a.start).startOf("day").toDate().getTime(),a.end=m(a.end).endOf("day").toDate().getTime()):(a.start=m().toDate().getTime(),a.end=m().add(1,"hour").toDate().getTime());break;case"start":let r=m(t);r.isValid()&&(a.start=r.set({hour:0,minute:0,second:0,millisecond:0}).toDate().getTime(),"validityRecurrence"===this.getValidityType()&&(i.dtstart=r.toDate(),this._rrule=new y(i)));break;case"end":let l=m(t);l.isValid()&&(a.end=l.set({hour:23,minute:59,second:0,millisecond:0}).toDate().getTime());break;case"never-ends":t?delete i.until:i.until=m().add(1,"year").toDate(),"validityRecurrence"===this.getValidityType()&&(this._rrule=new y(i));break;case"byweekday":i.byweekday||(i.byweekday=[]),Array.isArray(i.byweekday)||(i.byweekday=[i.byweekday]),i.byweekday=[],t.forEach(t=>{let e=this.getWeekDay(t);e&&i.byweekday.push(e)}),"validityRecurrence"===this.getValidityType()&&(this._rrule=new y(i));break;case"until":if(this._rrule.options.until){let e=m(t);i.until=new Date(m(i.until).set({year:e.year(),month:e.month(),date:e.date()}).format())}"validityRecurrence"===this.getValidityType()&&(this._rrule=new y(i));break;case"dtstart-time":let s=t.split(":");i?i.dtstart=m(i.dtstart).set({hour:s[0],minute:s[1],second:0,millisecond:0}).toDate():i=new y({dtstart:m(this._validity.start).set({hour:s[0],minute:s[1],second:0,millisecond:0}).toDate()}).origOptions,a.start=m(i.dtstart).toDate().getTime(),"validityRecurrence"===this.getValidityType()&&(this._rrule=new y(i));break;case"until-time":let o=t.split(":");this._rrule&&this._rrule.options.until&&(i?i.until=m(i.until).set({hour:o[0],minute:o[1],second:0,millisecond:0}).toDate():i=new y({until:m(this._validity.end).set({hour:o[0],minute:o[1],second:0,millisecond:0}).toDate()}).origOptions),a.end=m(a.end).set({hour:o[0],minute:o[1],second:0,millisecond:0}).toDate().getTime(),"validityRecurrence"===this.getValidityType()&&(this._rrule=new y(i))}this._validity=Object.assign({},a),this._dialog.requestUpdate()}timeLabel(){if("validityAlways"===this.getValidityType())return o.t("validityAlways");if(this._validity&&this._rrule){let t=this._validity,e=m(t.end).diff(t.start,"days"),i="";return this.isAllDay()?(e>0&&(i=" "+o.t("forDays",{days:e})),this._rrule.toText()+i):(e>0&&(i=o.t("fromToDays",{start:m(t.start).format("HH:mm"),end:m(t.end).format("HH:mm"),days:e})),0===e&&(i=o.t("fromTo",{start:m(t.start).format("HH:mm"),end:m(t.end).format("HH:mm")})),this._rrule.toText()+" "+i)}if(this._validity){let t="DD-MM-YYYY";return this.isAllDay()||(t="DD-MM-YYYY HH:mm"),o.t("activeFromTo",{start:m(this._validity.start).format(t),end:m(this._validity.end).format(t)})}}setValidityType(t){if(this.ruleset){switch(!this.ruleset.meta&&(this.ruleset.meta={}),t){case"validityAlways":delete this.ruleset.meta.validity,this._validity=void 0,this._rrule=void 0;break;case"validityPeriod":this._validity={start:m().startOf("day").toDate().getTime(),end:m().endOf("day").toDate().getTime()},this._rrule=void 0;break;case"validityRecurrence":this._validity||(this._validity={start:m().startOf("day").toDate().getTime(),end:m().endOf("day").toDate().getTime()}),this._rrule=new y({freq:y.DAILY,dtstart:new Date})}this._dialog.requestUpdate()}}getValidityType(){if(this._validity)if(this._rrule)return"validityRecurrence";else return"validityPeriod";return"validityAlways"}render(){return this.ruleset?t`
2
+ <or-mwc-input outlined .type="${s.BUTTON}" label="${this.timeLabel()}" @or-mwc-input-changed="${()=>this.showDialog()}"></or-mwc-input>
3
+ `:t``}showDialog(){this._dialog=u(new d().setHeading(o.t("scheduleRuleActivity")).setStyles(t`
4
+ <style>
5
+ .mdc-dialog__surface {
6
+ overflow-x: visible !important;
7
+ overflow-y: visible !important;
95
8
  }
96
- }
97
- break;
98
- case "end":
99
- const newEndDate = moment(value);
100
- if (newEndDate.isValid()) {
101
- validity.end = newEndDate.set({ hour: 23, minute: 59, second: 0, millisecond: 0 }).toDate().getTime();
102
- }
103
- break;
104
- case "never-ends":
105
- if (value) {
106
- delete origOptions.until;
107
- }
108
- else {
109
- origOptions.until = moment().add(1, 'year').toDate();
110
- }
111
- if (this.getValidityType() === "validityRecurrence")
112
- this._rrule = new RRule(origOptions);
113
- break;
114
- case "byweekday":
115
- if (!origOptions.byweekday)
116
- origOptions.byweekday = [];
117
- if (!Array.isArray(origOptions.byweekday))
118
- origOptions.byweekday = [origOptions.byweekday];
119
- const newDays = value;
120
- origOptions.byweekday = [];
121
- newDays.forEach((d) => {
122
- const weekDay = this.getWeekDay(d);
123
- if (weekDay) {
124
- origOptions.byweekday.push(weekDay);
9
+
10
+ #dialog-content {
11
+ overflow: visible;
125
12
  }
126
- });
127
- if (this.getValidityType() === "validityRecurrence")
128
- this._rrule = new RRule(origOptions);
129
- break;
130
- case "until":
131
- if (this._rrule.options.until) {
132
- const newDate = moment(value);
133
- origOptions.until = new Date(moment(origOptions.until).set({ year: newDate.year(), month: newDate.month(), date: newDate.date() }).format());
134
- }
135
- if (this.getValidityType() === "validityRecurrence")
136
- this._rrule = new RRule(origOptions);
137
- break;
138
- case "dtstart-time":
139
- const timeParts = value.split(':');
140
- if (origOptions) {
141
- origOptions.dtstart = moment(origOptions.dtstart).set({ hour: timeParts[0], minute: timeParts[1], second: 0, millisecond: 0 }).toDate();
142
- }
143
- else {
144
- origOptions = new RRule({
145
- dtstart: moment(this._validity.start).set({ hour: timeParts[0], minute: timeParts[1], second: 0, millisecond: 0 }).toDate()
146
- }).origOptions;
147
- }
148
- validity.start = moment(origOptions.dtstart).toDate().getTime();
149
- if (this.getValidityType() === "validityRecurrence")
150
- this._rrule = new RRule(origOptions);
151
- break;
152
- case "until-time":
153
- const untilParts = value.split(':');
154
- if (this._rrule && this._rrule.options.until) {
155
- if (origOptions) {
156
- origOptions.until = moment(origOptions.until).set({ hour: untilParts[0], minute: untilParts[1], second: 0, millisecond: 0 }).toDate();
157
- }
158
- else {
159
- origOptions = new RRule({
160
- until: moment(this._validity.end).set({ hour: untilParts[0], minute: untilParts[1], second: 0, millisecond: 0 }).toDate()
161
- }).origOptions;
162
- }
163
- }
164
- validity.end = moment(validity.end).set({ hour: untilParts[0], minute: untilParts[1], second: 0, millisecond: 0 }).toDate().getTime();
165
- if (this.getValidityType() === "validityRecurrence")
166
- this._rrule = new RRule(origOptions);
167
- break;
168
- }
169
- this._validity = Object.assign({}, validity);
170
- this._dialog.requestUpdate();
171
- }
172
- timeLabel() {
173
- if (this.getValidityType() === "validityAlways") {
174
- return i18next.t("validityAlways");
175
- }
176
- else if (this._validity && this._rrule) {
177
- const validity = this._validity;
178
- const diff = moment(validity.end).diff(validity.start, "days");
179
- let diffString = "";
180
- if (this.isAllDay()) {
181
- if (diff > 0)
182
- diffString = " " + i18next.t('forDays', { days: diff });
183
- return this._rrule.toText() + diffString;
184
- }
185
- else {
186
- if (diff > 0)
187
- diffString = i18next.t("fromToDays", { start: moment(validity.start).format("HH:mm"), end: moment(validity.end).format("HH:mm"), days: diff });
188
- if (diff === 0)
189
- diffString = i18next.t("fromTo", { start: moment(validity.start).format("HH:mm"), end: moment(validity.end).format("HH:mm") });
190
- return this._rrule.toText() + " " + diffString;
191
- }
192
- }
193
- else if (this._validity) {
194
- let format = "DD-MM-YYYY";
195
- if (!this.isAllDay())
196
- format = "DD-MM-YYYY HH:mm";
197
- return i18next.t("activeFromTo", { start: moment(this._validity.start).format(format), end: moment(this._validity.end).format(format) });
198
- }
199
- }
200
- setValidityType(value) {
201
- if (!this.ruleset)
202
- return;
203
- if (!this.ruleset.meta)
204
- this.ruleset.meta = {};
205
- switch (value) {
206
- case "validityAlways":
207
- delete this.ruleset.meta["validity"];
208
- this._validity = undefined;
209
- this._rrule = undefined;
210
- break;
211
- case "validityPeriod":
212
- this._validity = {
213
- start: moment().startOf("day").toDate().getTime(),
214
- end: moment().endOf("day").toDate().getTime()
215
- };
216
- this._rrule = undefined;
217
- break;
218
- case "validityRecurrence":
219
- if (!this._validity) {
220
- this._validity = {
221
- start: moment().startOf("day").toDate().getTime(),
222
- end: moment().endOf("day").toDate().getTime()
223
- };
224
- }
225
- this._rrule = new RRule({
226
- freq: RRule.DAILY,
227
- dtstart: new Date()
228
- });
229
- break;
230
- }
231
- this._dialog.requestUpdate();
232
- }
233
- getValidityType() {
234
- if (this._validity) {
235
- if (this._rrule) {
236
- return "validityRecurrence";
237
- }
238
- else {
239
- return "validityPeriod";
240
- }
241
- }
242
- return "validityAlways";
243
- }
244
- render() {
245
- if (!this.ruleset)
246
- return html ``;
247
- return html `
248
- <or-mwc-input outlined .type="${InputType.BUTTON}" label="${this.timeLabel()}" @or-mwc-input-changed="${() => this.showDialog()}"></or-mwc-input>
249
- `;
250
- }
251
- showDialog() {
252
- this._dialog = showDialog(new OrMwcDialog()
253
- .setHeading(i18next.t("scheduleRuleActivity"))
254
- .setStyles(html `
255
- <style>
256
- .mdc-dialog__surface {
257
- overflow-x: visible !important;
258
- overflow-y: visible !important;
259
- }
260
-
261
- #dialog-content {
262
- overflow: visible;
263
- }
264
-
265
- @media only screen and (max-width: 1279px) {
266
- .mdc-dialog__surface {
267
- overflow-x: auto !important;
268
- overflow-y: auto !important;
269
- }
270
-
271
- #dialog-content {
272
- min-height: 230px;
273
- overflow: auto;
274
- }
275
- }
276
- </style>`)
277
- .setActions([
278
- {
279
- actionName: "cancel",
280
- content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" label="cancel"></or-mwc-input>`,
281
- action: () => {
282
- this._dialog = undefined;
283
- }
284
- },
285
- {
286
- actionName: "ok",
287
- default: true,
288
- content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" label="apply"></or-mwc-input>`,
289
- action: () => {
290
- if (this.ruleset && this.ruleset.meta) {
291
- if (this.getValidityType() === "validityAlways") {
292
- delete this.ruleset.meta["validity"];
13
+
14
+ @media only screen and (max-width: 1279px) {
15
+ .mdc-dialog__surface {
16
+ overflow-x: auto !important;
17
+ overflow-y: auto !important;
293
18
  }
294
- else {
295
- if (this.getValidityType() === "validityRecurrence") {
296
- this._validity.recurrence = this._rrule.toString().split("RRULE:")[1];
297
- }
298
- this.ruleset.meta["validity"] = this._validity;
19
+
20
+ #dialog-content {
21
+ min-height: 230px;
22
+ overflow: auto;
299
23
  }
300
- this.dispatchEvent(new OrRulesRuleChangedEvent(true));
301
- this._dialog = undefined;
302
24
  }
303
- }
304
- },
305
- ])
306
- .setContent(() => this.getDialogContent())
307
- .setDismissAction(null));
308
- }
309
- getDialogContent() {
310
- const options = [RRule.MO.toString(), RRule.TU.toString(), RRule.WE.toString(), RRule.TH.toString(), RRule.FR.toString(), RRule.SA.toString(), RRule.SU.toString()];
311
- const validityTypes = ["validityAlways", "validityPeriod", "validityRecurrence"];
312
- const validityType = this.getValidityType();
313
- const selectedOptions = this._rrule && this._rrule.options && this._rrule.options.byweekday ? this._rrule.options.byweekday.map(day => new Weekday(day).toString()) : [];
314
- const validity = this._validity;
315
- return html `
316
- <div style="min-width: 635px; display:grid; flex-direction: row;">
317
- <div class="layout horizontal">
318
- <or-mwc-input style="min-width: 280px;" .value="${validityType}" .type="${InputType.SELECT}" .options="${validityTypes}" @or-mwc-input-changed="${(e) => this.setValidityType(e.detail.value)}" ></or-mwc-input>
319
- </div>
320
-
321
- ${validity && (validityType === "validityPeriod" || validityType === "validityRecurrence") ? html `
322
- <label style="display:block; margin-top: 20px;"><or-translate value="period"></or-translate></label>
323
- <div style="display: flex; justify-content: space-between;" class="layout horizontal">
324
- <div>
325
- <or-mwc-input value="${moment(validity.start).format("YYYY-MM-DD")}" .type="${InputType.DATE}" @or-mwc-input-changed="${(e) => this.setRRuleValue(e.detail.value, "start")}" .label="${i18next.t("from")}"></or-mwc-input>
326
- <or-mwc-input .disabled=${this.isAllDay()} .value="${moment(validity.start).format("HH:mm")}" .type="${InputType.TIME}" @or-mwc-input-changed="${(e) => this.setRRuleValue(e.detail.value, "dtstart-time")}" .label="${i18next.t("from")}"></or-mwc-input>
327
- </div>
328
- <div>
329
- <or-mwc-input .value="${moment(validity.end).format("YYYY-MM-DD")}" .type="${InputType.DATE}" @or-mwc-input-changed="${(e) => this.setRRuleValue(e.detail.value, "end")}" .label="${i18next.t("to")}"></or-mwc-input>
330
- <or-mwc-input .disabled=${this.isAllDay()} .value="${moment(validity.end).format("HH:mm")}" .type="${InputType.TIME}" @or-mwc-input-changed="${(e) => this.setRRuleValue(e.detail.value, "until-time")}" .label="${i18next.t("to")}"></or-mwc-input>
331
- </div>
332
- </div>
333
-
334
- <div class="layout horizontal">
335
- <or-mwc-input .value=${this.isAllDay()} @or-mwc-input-changed="${(e) => this.setRRuleValue(e.detail.value, "all-day")}" .type="${InputType.CHECKBOX}" .label="${i18next.t("allDay")}"></or-mwc-input>
336
- </div>
337
- ` : ``}
338
-
339
- ${validityType === "validityRecurrence" ? html `
340
- <label style="display: block; margin-top: 20px;"><or-translate value="repeatOccurrenceEvery"></or-translate></label>
341
- <div class="layout horizontal">
342
- <or-mwc-input .value="${selectedOptions}"
343
- .type="${InputType.CHECKBOX_LIST}"
344
- .options="${options}"
345
- .label="${i18next.t("daysOfTheWeek")}"
346
- @or-mwc-input-changed="${(e) => {
347
- this.setRRuleValue(e.detail.value, "byweekday");
348
- }}" ></or-mwc-input>
349
- </div>
350
-
351
- <label style="display:block; margin-top: 20px;"><or-translate value="repetitionEnds"></or-translate></label>
352
- <div class="layout horizontal">
353
- <or-mwc-input .value="${!this._rrule.options.until}" @or-mwc-input-changed="${(e) => this.setRRuleValue(e.detail.value, "never-ends")}" .type="${InputType.CHECKBOX}" .label="${i18next.t("never")}"></or-mwc-input>
354
- </div>
355
- <div class="layout horizontal">
356
- <or-mwc-input ?disabled="${!this._rrule.options.until}" .value="${this._rrule.options.until ? moment(this._rrule.options.until).format("YYYY-MM-DD") : moment().add(1, 'year').format('YYYY-MM-DD')}" .type="${InputType.DATE}" @or-mwc-input-changed="${(e) => this.setRRuleValue(e.detail.value, "until")}" .label="${i18next.t("to")}"></or-mwc-input>
357
- </div>
358
- ` : ``}
359
- </div>`;
360
- }
361
- };
362
- __decorate([
363
- property({ type: Object })
364
- ], OrRuleValidity.prototype, "ruleset", void 0);
365
- __decorate([
366
- query("#radial-modal")
367
- ], OrRuleValidity.prototype, "dialog", void 0);
368
- __decorate([
369
- property()
370
- ], OrRuleValidity.prototype, "_validity", void 0);
371
- __decorate([
372
- property()
373
- ], OrRuleValidity.prototype, "_rrule", void 0);
374
- OrRuleValidity = __decorate([
375
- customElement("or-rule-validity")
376
- ], OrRuleValidity);
377
- export { OrRuleValidity };
378
- //# sourceMappingURL=or-rule-validity.js.map
25
+ </style>`).setActions([{actionName:"cancel",content:t`<or-mwc-input class="button" .type="${s.BUTTON}" label="cancel"></or-mwc-input>`,action:()=>{this._dialog=void 0}},{actionName:"ok",default:!0,content:t`<or-mwc-input class="button" .type="${s.BUTTON}" label="apply"></or-mwc-input>`,action:()=>{this.ruleset&&this.ruleset.meta&&("validityAlways"===this.getValidityType()?delete this.ruleset.meta.validity:("validityRecurrence"===this.getValidityType()&&(this._validity.recurrence=this._rrule.toString().split("RRULE:")[1]),this.ruleset.meta.validity=this._validity),this.dispatchEvent(new l(!0)),this._dialog=void 0)}}]).setContent(()=>this.getDialogContent()).setDismissAction(null))}getDialogContent(){let e=[y.MO.toString(),y.TU.toString(),y.WE.toString(),y.TH.toString(),y.FR.toString(),y.SA.toString(),y.SU.toString()],i=this.getValidityType(),a=this._rrule&&this._rrule.options&&this._rrule.options.byweekday?this._rrule.options.byweekday.map(t=>new c(t).toString()):[],r=this._validity;return t`
26
+ <div style="min-width: 635px; display:grid; flex-direction: row;">
27
+ <div class="layout horizontal">
28
+ <or-mwc-input style="min-width: 280px;" .value="${i}" .type="${s.SELECT}" .options="${["validityAlways","validityPeriod","validityRecurrence"]}" @or-mwc-input-changed="${t=>this.setValidityType(t.detail.value)}" ></or-mwc-input>
29
+ </div>
30
+
31
+ ${r&&("validityPeriod"===i||"validityRecurrence"===i)?t`
32
+ <label style="display:block; margin-top: 20px;"><or-translate value="period"></or-translate></label>
33
+ <div style="display: flex; justify-content: space-between;" class="layout horizontal">
34
+ <div>
35
+ <or-mwc-input value="${m(r.start).format("YYYY-MM-DD")}" .type="${s.DATE}" @or-mwc-input-changed="${t=>this.setRRuleValue(t.detail.value,"start")}" .label="${o.t("from")}"></or-mwc-input>
36
+ <or-mwc-input .disabled=${this.isAllDay()} .value="${m(r.start).format("HH:mm")}" .type="${s.TIME}" @or-mwc-input-changed="${t=>this.setRRuleValue(t.detail.value,"dtstart-time")}" .label="${o.t("from")}"></or-mwc-input>
37
+ </div>
38
+ <div>
39
+ <or-mwc-input .value="${m(r.end).format("YYYY-MM-DD")}" .type="${s.DATE}" @or-mwc-input-changed="${t=>this.setRRuleValue(t.detail.value,"end")}" .label="${o.t("to")}"></or-mwc-input>
40
+ <or-mwc-input .disabled=${this.isAllDay()} .value="${m(r.end).format("HH:mm")}" .type="${s.TIME}" @or-mwc-input-changed="${t=>this.setRRuleValue(t.detail.value,"until-time")}" .label="${o.t("to")}"></or-mwc-input>
41
+ </div>
42
+ </div>
43
+
44
+ <div class="layout horizontal">
45
+ <or-mwc-input .value=${this.isAllDay()} @or-mwc-input-changed="${t=>this.setRRuleValue(t.detail.value,"all-day")}" .type="${s.CHECKBOX}" .label="${o.t("allDay")}"></or-mwc-input>
46
+ </div>
47
+ `:""}
48
+
49
+ ${"validityRecurrence"===i?t`
50
+ <label style="display: block; margin-top: 20px;"><or-translate value="repeatOccurrenceEvery"></or-translate></label>
51
+ <div class="layout horizontal">
52
+ <or-mwc-input .value="${a}"
53
+ .type="${s.CHECKBOX_LIST}"
54
+ .options="${e}"
55
+ .label="${o.t("daysOfTheWeek")}"
56
+ @or-mwc-input-changed="${t=>{this.setRRuleValue(t.detail.value,"byweekday")}}" ></or-mwc-input>
57
+ </div>
58
+
59
+ <label style="display:block; margin-top: 20px;"><or-translate value="repetitionEnds"></or-translate></label>
60
+ <div class="layout horizontal">
61
+ <or-mwc-input .value="${!this._rrule.options.until}" @or-mwc-input-changed="${t=>this.setRRuleValue(t.detail.value,"never-ends")}" .type="${s.CHECKBOX}" .label="${o.t("never")}"></or-mwc-input>
62
+ </div>
63
+ <div class="layout horizontal">
64
+ <or-mwc-input ?disabled="${!this._rrule.options.until}" .value="${this._rrule.options.until?m(this._rrule.options.until).format("YYYY-MM-DD"):m().add(1,"year").format("YYYY-MM-DD")}" .type="${s.DATE}" @or-mwc-input-changed="${t=>this.setRRuleValue(t.detail.value,"until")}" .label="${o.t("to")}"></or-mwc-input>
65
+ </div>
66
+ `:""}
67
+ </div>`}};__decorate([a({type:Object})],OrRuleValidity.prototype,"ruleset",void 0),__decorate([r("#radial-modal")],OrRuleValidity.prototype,"dialog",void 0),__decorate([a()],OrRuleValidity.prototype,"_validity",void 0),__decorate([a()],OrRuleValidity.prototype,"_rrule",void 0),OrRuleValidity=__decorate([i("or-rule-validity")],OrRuleValidity);export{OrRuleValidity};