tpmkms_4wp 9.3.0-beta.32 → 9.3.0-beta.34
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.
- package/common/reminders.js +33 -28
- package/package.json +2 -2
package/common/reminders.js
CHANGED
@@ -16,19 +16,19 @@ const helpers = require('./helpers')
|
|
16
16
|
remind every truck driver to whatever tomorrow at 8 am
|
17
17
|
*/
|
18
18
|
|
19
|
-
const query = (missing,
|
19
|
+
const query = (missing, reminder_id) => {
|
20
20
|
return {
|
21
21
|
where: where(),
|
22
22
|
// oneShot: false,
|
23
23
|
onNevermind: ({verbatim, ...args}) => {
|
24
24
|
const api = args.kms.reminders.api
|
25
|
-
api.delete_reminder(
|
25
|
+
api.delete_reminder(reminder_id)
|
26
26
|
},
|
27
27
|
|
28
|
-
matchq: ({ api, context }) => api.missing(missing,
|
28
|
+
matchq: ({ api, context }) => api.missing(missing, reminder_id) && context.marker == 'controlEnd',
|
29
29
|
applyq: async ({ api, context, gs }) => {
|
30
30
|
context.cascade = false
|
31
|
-
const item = api.missing(missing,
|
31
|
+
const item = api.missing(missing, reminder_id)
|
32
32
|
let who
|
33
33
|
if (Array.isArray(item.who)) {
|
34
34
|
who = await gs(item.who.map((who) => who.text), ', ', ' and ')
|
@@ -48,7 +48,7 @@ const query = (missing, reminder) => {
|
|
48
48
|
},
|
49
49
|
|
50
50
|
matchr: ({ isA, api, context }) => {
|
51
|
-
const gotADate = ((isA(context.marker, 'onDateValue_dates') || isA(context.marker, 'dateTimeSelector')) && api.missing(missing,
|
51
|
+
const gotADate = ((isA(context.marker, 'onDateValue_dates') || isA(context.marker, 'dateTimeSelector')) && api.missing(missing, reminder_id))
|
52
52
|
if (missing == 'missingDate') {
|
53
53
|
return gotADate
|
54
54
|
} else {
|
@@ -58,7 +58,7 @@ const query = (missing, reminder) => {
|
|
58
58
|
return false
|
59
59
|
},
|
60
60
|
applyr: async ({ context, api, gp }) => {
|
61
|
-
const item = api.missing(missing,
|
61
|
+
const item = api.missing(missing, reminder_id)
|
62
62
|
await api.update({ id: item.id, dateTimeSelector: context, dateTimeSelectorText: await gp(context) })
|
63
63
|
}
|
64
64
|
}
|
@@ -87,7 +87,7 @@ class API {
|
|
87
87
|
|
88
88
|
// addUser to current
|
89
89
|
addUser(user) {
|
90
|
-
const reminder = this.
|
90
|
+
const reminder = this.reminders().find((r) => r.id == this._objects.current)
|
91
91
|
if (reminder) {
|
92
92
|
if (Array.isArray(reminder.who)) {
|
93
93
|
reminder.who = [...reminder.who, user]
|
@@ -98,7 +98,7 @@ class API {
|
|
98
98
|
}
|
99
99
|
|
100
100
|
removeUser(user) {
|
101
|
-
const reminder = this.
|
101
|
+
const reminder = this.reminders().find((r) => r.id == this._objects.current)
|
102
102
|
if (reminder) {
|
103
103
|
reminder.who = reminder.who.filter((who) => who.remindee_id != user.remindee_id)
|
104
104
|
}
|
@@ -132,7 +132,8 @@ class API {
|
|
132
132
|
getCurrent() {
|
133
133
|
}
|
134
134
|
|
135
|
-
missing(what,
|
135
|
+
missing(what, reminder_id) {
|
136
|
+
const reminder = this.reminder(reminder_id)
|
136
137
|
if (what == 'missingReminder' && !reminder.text) {
|
137
138
|
return { when: true, who: reminder.who, text: reminder.text, id: reminder.id, missingReminder: true }
|
138
139
|
}
|
@@ -141,26 +142,38 @@ class API {
|
|
141
142
|
}
|
142
143
|
}
|
143
144
|
|
145
|
+
reminder(id) {
|
146
|
+
return this._objects.reminders.find((reminder) => reminder.id == id)
|
147
|
+
}
|
148
|
+
|
149
|
+
reminders() {
|
150
|
+
return this._objects.reminders
|
151
|
+
}
|
152
|
+
|
153
|
+
setReminders(reminders) {
|
154
|
+
this._objects.reminders = reminders
|
155
|
+
}
|
156
|
+
|
144
157
|
askAbout(what) {
|
145
158
|
const items = []
|
146
|
-
for (const item of this.
|
147
|
-
if (this.missing('missingReminder', item)) {
|
148
|
-
items.push(this.missing('missingReminder', item))
|
159
|
+
for (const item of this.reminders()) {
|
160
|
+
if (this.missing('missingReminder', item.id)) {
|
161
|
+
items.push(this.missing('missingReminder', item.id))
|
149
162
|
}
|
150
|
-
if (this.missing('missingDate', item)) {
|
151
|
-
items.push(this.missing('missingDate', item))
|
163
|
+
if (this.missing('missingDate', item.id)) {
|
164
|
+
items.push(this.missing('missingDate', item.id))
|
152
165
|
}
|
153
166
|
}
|
154
167
|
return items
|
155
168
|
}
|
156
169
|
|
157
170
|
show() {
|
158
|
-
if (this.
|
171
|
+
if (this.reminders().length == 0) {
|
159
172
|
return "There are no reminders"
|
160
173
|
}
|
161
174
|
let s = 'The reminders are\n'
|
162
175
|
let counter = 1
|
163
|
-
for (const item of this.
|
176
|
+
for (const item of this.reminders()) {
|
164
177
|
s += ` ${counter}. ${item.text}\n`
|
165
178
|
counter += 1
|
166
179
|
}
|
@@ -168,21 +181,13 @@ class API {
|
|
168
181
|
// -> return a table object. then have ability to talk about the table. maybe later let's focus on this for now
|
169
182
|
}
|
170
183
|
|
171
|
-
/*
|
172
|
-
delete_reminder(ordinal) {
|
173
|
-
if (ordinal < 1 || ordinal > this._objects.reminders.length) {
|
174
|
-
return `Not possible`
|
175
|
-
}
|
176
|
-
this._objects.reminders = this._objects.reminders.splice(ordinal, 1)
|
177
|
-
}
|
178
|
-
*/
|
179
184
|
delete_reminder(id) {
|
180
|
-
const reminder = this.
|
185
|
+
const reminder = this.reminders().find((reminder) => reminder.id)
|
181
186
|
if (reminder) {
|
182
187
|
if (reminder.cleanUp) {
|
183
188
|
reminder.cleanUp()
|
184
189
|
}
|
185
|
-
this.
|
190
|
+
this.setReminders(this._objects.reminders.filter((reminder) => reminder.id != id))
|
186
191
|
}
|
187
192
|
}
|
188
193
|
|
@@ -283,8 +288,8 @@ const template = {
|
|
283
288
|
// await api.instantiate(reminder)
|
284
289
|
await api.add(reminder)
|
285
290
|
reminder.cleanUp = ask([
|
286
|
-
query('missingReminder', reminder),
|
287
|
-
query('missingDate', reminder),
|
291
|
+
query('missingReminder', reminder.id),
|
292
|
+
query('missingDate', reminder.id),
|
288
293
|
])
|
289
294
|
},
|
290
295
|
},
|
package/package.json
CHANGED
@@ -341,8 +341,8 @@
|
|
341
341
|
"scriptjs": "^2.5.9",
|
342
342
|
"table": "^6.7.1",
|
343
343
|
"uuid": "^9.0.0",
|
344
|
-
"theprogrammablemind_4wp": "9.3.0-beta.
|
344
|
+
"theprogrammablemind_4wp": "9.3.0-beta.34"
|
345
345
|
},
|
346
|
-
"version": "9.3.0-beta.
|
346
|
+
"version": "9.3.0-beta.34",
|
347
347
|
"license": "UNLICENSED"
|
348
348
|
}
|