@mccaskie-labs/workbench-roster 0.1.0 → 0.2.0
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/CHANGELOG.md +10 -0
- package/README.md +2 -0
- package/dist/cli.js +0 -0
- package/dist/confirm.d.ts +60 -0
- package/dist/confirm.js +85 -0
- package/dist/errors.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/roster.d.ts +3 -2
- package/dist/roster.js +83 -14
- package/dist/styles.js +11 -9
- package/dist/types.d.ts +2 -0
- package/dist/ui.d.ts +7 -4
- package/dist/ui.js +71 -14
- package/dist/words.d.ts +1 -1
- package/dist/words.js +152 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-roster
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- The roster asks "Are you sure?" first. Take off the roster (`renderStaff`) no longer has a tick box: it opens a question that names the person and says their shifts from now on, their leave and their link go and that they're emailed, with "Yes, take {name} off" and "No, keep them on the roster". Email them their link asks first and says the old link and calendar feed stop; removing leave asks first and says the person is emailed; Publish and Send the changes (`renderWeek`) ask first and say how many people get the email; removing a shift asks first on a published week (one click on a draft). Each is a `<details>`, so it works with no script.
|
|
8
|
+
- **Breaking:** `rosterAction`'s `publish`, `remove_staff`, `send_link`, `remove_leave`, and `remove_shift` for a shift in a published week (or one it can't find in the posted `week`) refuse a post without `confirm=yes` with the new failure `confirm_needed` (409, "Please confirm first. Nothing has changed."). `remove_staff` without it was `bad_input` (400). A page that draws its own one-click button must ask first and post `confirm=yes`. The store methods are unchanged and need no flag.
|
|
9
|
+
- With a mailer, the person taken off the roster is now emailed (`roster.removed`): what happened, the shifts they lose with a cancelling calendar file, and that their page and feed stop. Removing leave emails the person which days are off the roster (`roster.leave_removed`). A failed email never fails the change.
|
|
10
|
+
- `roster.week()` answers `emailing`: how many people Publish or Send the changes would email now (0 without a mailer). `renderWeek` uses it in the question; a `WeekView` without it gets words with no number.
|
|
11
|
+
- `renderConfirm`, `confirmed` and `ConfirmOptions` are exported for an app's own pages. New words `confirm.no`, `error.confirm_needed`, `shift.remove.question`, `.consequence`, `.consequence_manual`, `.consequence_gone` and `.yes`, `week.publish.question`, `.consequence`, `.consequence_one`, `.consequence_none`, `.consequence_all`, `.yes` and `.no`, `week.send.question`, `.consequence`, `.consequence_one`, `.consequence_none`, `.consequence_all` and `.yes`, `staff.link.question`, `.consequence`, `.consequence_first`, `.yes` and `.no`, `staff.remove.question`, `.consequence`, `.yes` and `.no`, `leave.remove.question`, `.consequence` and `.yes`, and `email.removed.subject`, `.body` and `.next` and `email.leave_removed.subject`, `.body` and `.next`; `staff.remove_confirm` is gone. New classes `wb-roster-confirm` (now the question's `<details>`), `-confirm-open`, `-confirm-ask`, `-confirm-keep`, `-confirm-form`, `-confirm-question`, `-confirm-consequence` and `-confirm-yes`. The role tick boxes' label is now `wb-roster-tick` (it was `wb-roster-confirm`); `wb-roster-remove-form` is a `<div>`, and `wb-roster-danger`, `wb-roster-publish`, and `wb-roster-remove` and `wb-roster-secondary` where they ask first, are on the `<summary>` that opens the question.
|
|
12
|
+
|
|
3
13
|
## 0.1.0
|
|
4
14
|
|
|
5
15
|
- First version: staff, shifts and leave in the app's own database; publish a week and email each person their shifts with a calendar file; their own page and feed; changes emailed to the people they touch; the gaps check; `hoursFor()` for workbench-bookings' `settings`; the hours export; English, Tagalog and Taglish (docs/capabilities/21-roster.md).
|
package/README.md
CHANGED
|
@@ -32,6 +32,8 @@ const view = await roster.week(account, '2026-12-05') // any day in t
|
|
|
32
32
|
html(renderWeek(view, { config: roster.config, endpoint: '/app/roster', weekUrl: (w) => `/app/roster?week=${w}`, gaps: await roster.gaps(account, view.week) }))
|
|
33
33
|
html(renderStaff(await roster.staff(account), { config: roster.config, endpoint: '/app/roster', leave: await roster.leave(account) }))
|
|
34
34
|
const result = await rosterAction(roster, fields, account)
|
|
35
|
+
// publish, remove_staff, send_link, remove_leave, and remove_shift on a published week need confirm=yes
|
|
36
|
+
// (the "Are you sure?" button sends it); without it the answer is confirm_needed (409) and nothing changes.
|
|
35
37
|
|
|
36
38
|
// A person's own page and feed, by their secret (sent with roster.sendLink):
|
|
37
39
|
html(renderMyShifts((await roster.mine(token))!, { config: roster.config, feedUrl: `webcal://${host}/roster/feed/${token}.ics` }))
|
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface ConfirmOptions {
|
|
2
|
+
/** The tool's class prefix, without the trailing dash: "wb-booking". */
|
|
3
|
+
prefix: string;
|
|
4
|
+
/** Where the form posts. */
|
|
5
|
+
endpoint: string;
|
|
6
|
+
/** The hidden fields that say what to do: action, the thing's id or token. */
|
|
7
|
+
fields: Readonly<Record<string, string>>;
|
|
8
|
+
/** The first button's words: "Cancel". */
|
|
9
|
+
ask: string;
|
|
10
|
+
/** The first button's class, so it keeps the look it has in the tool's styles. */
|
|
11
|
+
askClass: string;
|
|
12
|
+
/** The question, naming the thing: "Cancel Sam's booking for Yoga on Monday 7 December at 6:00 pm?" */
|
|
13
|
+
question: string;
|
|
14
|
+
/** What happens next and who is told: "We'll email Sam to say it's cancelled." */
|
|
15
|
+
consequence?: string;
|
|
16
|
+
/** The button that does it, in its own words: "Yes, cancel this booking". */
|
|
17
|
+
yes: string;
|
|
18
|
+
/** The words that close the question again: "No, keep it". */
|
|
19
|
+
no: string;
|
|
20
|
+
/** A reason to send with it, when the action takes one. */
|
|
21
|
+
reason?: {
|
|
22
|
+
label: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
maxlength?: number;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** For deleting a lot at once: a word the person must type before the button works. */
|
|
28
|
+
type?: {
|
|
29
|
+
label: string;
|
|
30
|
+
word: string;
|
|
31
|
+
};
|
|
32
|
+
/** More fields for the question's form, as HTML the tool has already escaped (a second box, a choice). Drawn above the button. */
|
|
33
|
+
extra?: string;
|
|
34
|
+
/** Draw the question already showing: the page was drawn again to ask it. */
|
|
35
|
+
open?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** The button and its question. */
|
|
38
|
+
export declare function renderConfirm(o: ConfirmOptions): string;
|
|
39
|
+
/** Whether a post answered the question: confirm=yes and, where a word had to be typed, that word. */
|
|
40
|
+
export declare function confirmed(body: Readonly<Record<string, unknown>>, word?: string): boolean;
|
|
41
|
+
interface ConfirmStyle {
|
|
42
|
+
name: string;
|
|
43
|
+
element: string;
|
|
44
|
+
about: string;
|
|
45
|
+
css: string;
|
|
46
|
+
states?: readonly {
|
|
47
|
+
selector: string;
|
|
48
|
+
about: string;
|
|
49
|
+
css: string;
|
|
50
|
+
}[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The question's classes with their default rules, for the tool's styles.
|
|
54
|
+
* `v` reads one of the tool's own variables (text, muted, line, sunk, surface,
|
|
55
|
+
* radius, danger, on-danger, focus).
|
|
56
|
+
*/
|
|
57
|
+
export declare function confirmStyles(prefix: string, v: (name: string) => string, o?: {
|
|
58
|
+
reason?: boolean;
|
|
59
|
+
}): ConfirmStyle[];
|
|
60
|
+
export {};
|
package/dist/confirm.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// "Are you sure?" for the actions that cancel, decline or delete
|
|
2
|
+
// (docs/critical-actions-audit.md, "The standard"). The button a person presses first only opens
|
|
3
|
+
// the question: what is about to happen, named in full, and who will be told.
|
|
4
|
+
// The second button does it. It is a <details>, so it works with no script,
|
|
5
|
+
// and the post carries confirm=yes, which the action helpers insist on: a page
|
|
6
|
+
// that draws its own one-click button is refused with `confirm_needed`.
|
|
7
|
+
//
|
|
8
|
+
// This file is the same in every tool that asks (only the prefix differs), so
|
|
9
|
+
// a project restyles each tool's question by that tool's own class names.
|
|
10
|
+
const esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
11
|
+
const pattern = (word) => word.replace(/[.*+?^${}()|[\]\\\/-]/g, "\\$&");
|
|
12
|
+
/** The button and its question. */
|
|
13
|
+
export function renderConfirm(o) {
|
|
14
|
+
const p = o.prefix;
|
|
15
|
+
const hidden = Object.entries({ ...o.fields, confirm: "yes" })
|
|
16
|
+
.map(([k, v]) => `<input type="hidden" name="${esc(k)}" value="${esc(v)}">`)
|
|
17
|
+
.join("");
|
|
18
|
+
const reason = o.reason
|
|
19
|
+
? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.reason.label)}</span><input class="${p}-confirm-input" type="text" name="${esc(o.reason.name ?? "reason")}" maxlength="${o.reason.maxlength ?? 200}"${o.reason.required ? " required" : ""}></label>`
|
|
20
|
+
: "";
|
|
21
|
+
const type = o.type
|
|
22
|
+
? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.type.label)}</span><input class="${p}-confirm-input" type="text" name="confirm_word" required pattern="${esc(pattern(o.type.word))}" autocomplete="off" autocapitalize="off" spellcheck="false"></label>`
|
|
23
|
+
: "";
|
|
24
|
+
return `<details class="${p}-confirm"${o.open ? " open" : ""}><summary class="${p}-confirm-open ${esc(o.askClass)}"><span class="${p}-confirm-ask">${esc(o.ask)}</span><span class="${p}-confirm-keep">${esc(o.no)}</span></summary><form class="${p}-confirm-form" method="post" action="${esc(o.endpoint)}">${hidden}<p class="${p}-confirm-question">${esc(o.question)}</p>${o.consequence ? `<p class="${p}-confirm-consequence">${esc(o.consequence)}</p>` : ""}${reason}${o.extra ?? ""}${type}<button class="${p}-confirm-yes" type="submit">${esc(o.yes)}</button></form></details>`;
|
|
25
|
+
}
|
|
26
|
+
/** Whether a post answered the question: confirm=yes and, where a word had to be typed, that word. */
|
|
27
|
+
export function confirmed(body, word) {
|
|
28
|
+
if (body.confirm !== "yes" && body.confirm !== true)
|
|
29
|
+
return false;
|
|
30
|
+
return word === undefined || (typeof body.confirm_word === "string" && body.confirm_word.trim() === word);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The question's classes with their default rules, for the tool's styles.
|
|
34
|
+
* `v` reads one of the tool's own variables (text, muted, line, sunk, surface,
|
|
35
|
+
* radius, danger, on-danger, focus).
|
|
36
|
+
*/
|
|
37
|
+
export function confirmStyles(prefix, v, o = {}) {
|
|
38
|
+
const focus = { selector: ":focus-visible", about: "Has focus", css: `outline:none;box-shadow:0 0 0 3px ${v("focus")}` };
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
name: `${prefix}-confirm`,
|
|
42
|
+
element: "details",
|
|
43
|
+
about: "A button that asks \"Are you sure?\" before it cancels, declines or deletes",
|
|
44
|
+
css: "display:block",
|
|
45
|
+
states: [
|
|
46
|
+
{ selector: `[open]`, about: "The question is showing", css: `display:flex;flex-direction:column;align-items:flex-start;gap:.75rem;box-sizing:border-box;width:100%;padding:1rem;background:${v("sunk")};border:1px solid ${v("line")};border-radius:${v("radius")}` },
|
|
47
|
+
{ selector: `[open] > summary`, about: "\"No, keep it\" sits under the button that does it", css: "order:2" },
|
|
48
|
+
{ selector: `[open] .${prefix}-confirm-ask`, about: "The first button's words, hidden while the question shows", css: "display:none" },
|
|
49
|
+
{ selector: `[open] .${prefix}-confirm-keep`, about: "\"No, keep it\", shown while the question shows", css: "display:inline" },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: `${prefix}-confirm-open`,
|
|
54
|
+
element: "summary",
|
|
55
|
+
about: "The first button: it only opens the question",
|
|
56
|
+
css: "list-style:none",
|
|
57
|
+
states: [{ selector: "::-webkit-details-marker", about: "No arrow beside the button", css: "display:none" }],
|
|
58
|
+
},
|
|
59
|
+
{ name: `${prefix}-confirm-ask`, element: "span", about: "The first button's words", css: "display:inline" },
|
|
60
|
+
{ name: `${prefix}-confirm-keep`, element: "span", about: "\"No, keep it\": closes the question", css: `display:none;color:${v("text")}` },
|
|
61
|
+
{ name: `${prefix}-confirm-form`, element: "form", about: "The question and the button that does it", css: "display:grid;gap:.75rem;justify-items:start;width:100%" },
|
|
62
|
+
{ name: `${prefix}-confirm-question`, element: "p", about: "What is about to happen, naming the thing", css: `margin:0;font-weight:600;color:${v("text")}` },
|
|
63
|
+
{ name: `${prefix}-confirm-consequence`, element: "p", about: "What happens next and who is told", css: `margin:0;color:${v("muted")}` },
|
|
64
|
+
...(o.reason
|
|
65
|
+
? [
|
|
66
|
+
{ name: `${prefix}-confirm-field`, element: "label", about: "The reason, or the word to type", css: "display:grid;gap:.25rem;width:100%" },
|
|
67
|
+
{ name: `${prefix}-confirm-label`, element: "span", about: "What to type there", css: `color:${v("muted")}` },
|
|
68
|
+
{
|
|
69
|
+
name: `${prefix}-confirm-input`,
|
|
70
|
+
element: "input",
|
|
71
|
+
about: "Where it is typed",
|
|
72
|
+
css: `box-sizing:border-box;width:100%;min-height:2.75rem;padding:.5rem .75rem;font:inherit;color:${v("text")};background:${v("surface")};border:1px solid ${v("line")};border-radius:${v("radius")}`,
|
|
73
|
+
states: [focus],
|
|
74
|
+
},
|
|
75
|
+
]
|
|
76
|
+
: []),
|
|
77
|
+
{
|
|
78
|
+
name: `${prefix}-confirm-yes`,
|
|
79
|
+
element: "button",
|
|
80
|
+
about: "The button that does it",
|
|
81
|
+
css: `display:inline-flex;align-items:center;justify-content:center;min-height:2.75rem;padding:0 1rem;font:inherit;font-weight:600;border-radius:${v("radius")};cursor:pointer;color:${v("on-danger")};background:${v("danger")};border:1px solid ${v("danger")}`,
|
|
82
|
+
states: [focus],
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export type RosterErrorCode =
|
|
|
15
15
|
| "taken"
|
|
16
16
|
/** Copying a week: the week copied into already has shifts. */
|
|
17
17
|
| "not_empty"
|
|
18
|
+
/** Publishing, taking someone off, emailing a new link, removing leave, or removing a shift from a published week arrived without the answer to "Are you sure?" (confirm=yes). Nothing was changed. */
|
|
19
|
+
| "confirm_needed"
|
|
18
20
|
/** The database refused or failed. */
|
|
19
21
|
| "store_failed";
|
|
20
22
|
export declare class RosterError extends Error {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { csvCell, hoursCsv, paidHours } from "./csv.ts";
|
|
|
6
6
|
export { rosterMigration } from "./migration.ts";
|
|
7
7
|
export { STARTER_ROSTER } from "./starters.ts";
|
|
8
8
|
export { renderMyShifts, renderStaff, renderWeek, rosterAction, type ActionResult, type MineOptions, type RosterDone, type StaffOptions, type WeekOptions } from "./ui.ts";
|
|
9
|
+
export { confirmed, renderConfirm, type ConfirmOptions } from "./confirm.ts";
|
|
9
10
|
export { type Words } from "./format.ts";
|
|
10
11
|
export { ROSTER_WORDS, ROSTER_WORD_KEYS, type RosterWordKey } from "./words.ts";
|
|
11
12
|
export { ROSTER_STYLES } from "./styles.ts";
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { csvCell, hoursCsv, paidHours } from "./csv.js";
|
|
|
14
14
|
export { rosterMigration } from "./migration.js";
|
|
15
15
|
export { STARTER_ROSTER } from "./starters.js";
|
|
16
16
|
export { renderMyShifts, renderStaff, renderWeek, rosterAction } from "./ui.js";
|
|
17
|
+
export { confirmed, renderConfirm } from "./confirm.js";
|
|
17
18
|
export {} from "./format.js";
|
|
18
19
|
export { ROSTER_WORDS, ROSTER_WORD_KEYS } from "./words.js";
|
|
19
20
|
export { ROSTER_STYLES } from "./styles.js";
|
package/dist/roster.d.ts
CHANGED
|
@@ -86,14 +86,14 @@ export interface Roster {
|
|
|
86
86
|
}): Promise<Staff[]>;
|
|
87
87
|
/** Adds a person, or changes one (with id). Refused with `taken` when someone on the roster has that email or resource. */
|
|
88
88
|
saveStaff(account: string, input: StaffInput): Promise<Staff>;
|
|
89
|
-
/** Takes a person off: their link stops, their shifts from now on go (and those weeks' changes are sent), their past shifts stay for the export. */
|
|
89
|
+
/** Takes a person off: their link stops, their shifts from now on and their leave go (and those weeks' changes are sent), their past shifts stay for the export. With a mailer, the person is emailed that they're off, with their cancelled shifts. */
|
|
90
90
|
removeStaff(account: string, id: string): Promise<boolean>;
|
|
91
91
|
/** Makes a person a new link secret (the old one stops) and emails them their page and calendar feed. */
|
|
92
92
|
sendLink(account: string, id: string): Promise<{
|
|
93
93
|
token: string;
|
|
94
94
|
emailed: number;
|
|
95
95
|
}>;
|
|
96
|
-
/** Everything the owner's page shows for a week (any day in it). */
|
|
96
|
+
/** Everything the owner's page shows for a week (any day in it), with how many people Publish or Send the changes would email (`emailing`). */
|
|
97
97
|
week(account: string, week: string): Promise<WeekView>;
|
|
98
98
|
addShift(account: string, input: ShiftInput): Promise<Shift>;
|
|
99
99
|
updateShift(account: string, id: string, input: ShiftInput): Promise<Shift>;
|
|
@@ -125,6 +125,7 @@ export interface Roster {
|
|
|
125
125
|
leave: Leave;
|
|
126
126
|
clashes: Shift[];
|
|
127
127
|
}>;
|
|
128
|
+
/** Removes days away. With a mailer, the person is emailed that their leave is off the roster. */
|
|
128
129
|
removeLeave(account: string, id: string): Promise<boolean>;
|
|
129
130
|
/** Leave overlapping a range (default from today for a year). */
|
|
130
131
|
leave(account: string, opts?: {
|
package/dist/roster.js
CHANGED
|
@@ -150,6 +150,24 @@ export function createRoster(opts) {
|
|
|
150
150
|
const shiftLine = (s) => [spanText(s.starts_at, s.ends_at, tz, locale), roleTitle(s.role), s.break_minutes ? say("shift.break", { minutes: s.break_minutes }) : null, s.note].filter(Boolean).join(" · ");
|
|
151
151
|
const digestOf = (shifts) => sha256(JSON.stringify(shifts.map((s) => [s.id, s.starts_at, s.ends_at, s.role, s.break_minutes, s.note, s.sequence])));
|
|
152
152
|
const mailKey = async (key, email) => `roster:${await sha256(`${key}\n${email.toLowerCase()}`)}`;
|
|
153
|
+
/** The active people whose shifts in a week differ from what they were last sent: who a send emails. */
|
|
154
|
+
async function toEmail(shifts, staff, sent) {
|
|
155
|
+
const before = new Map(sent.map((s) => [s.staff, s]));
|
|
156
|
+
const out = [];
|
|
157
|
+
for (const person of staff) {
|
|
158
|
+
if (!person.active)
|
|
159
|
+
continue;
|
|
160
|
+
const theirs = shifts.filter((s) => s.staff === person.id);
|
|
161
|
+
const last = before.get(person.id);
|
|
162
|
+
if (!theirs.length && !last)
|
|
163
|
+
continue;
|
|
164
|
+
const digest = await digestOf(theirs);
|
|
165
|
+
if (last?.digest === digest)
|
|
166
|
+
continue;
|
|
167
|
+
out.push({ person, theirs, last, digest });
|
|
168
|
+
}
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
153
171
|
/** Emails each active person whose shifts in a published week differ from what they were last sent. Marks the week sent when nothing failed. */
|
|
154
172
|
async function sendWeek(account, week) {
|
|
155
173
|
const state = normWeek(await q("send", "roster_week_get", { p_account: account, p_week: week }), week);
|
|
@@ -160,20 +178,12 @@ export function createRoster(opts) {
|
|
|
160
178
|
q("send", "roster_staff_list", { p_account: account, p_all: false }).then((r) => r.map(normStaff)),
|
|
161
179
|
q("send", "roster_sent_list", { p_account: account, p_week: week }),
|
|
162
180
|
]);
|
|
163
|
-
const before = new Map(sent.map((s) => [s.staff, s]));
|
|
164
181
|
const biz = await business(account);
|
|
165
182
|
const weekName = dateText(week, locale);
|
|
166
183
|
const title = (s) => [roleTitle(s.role) ?? say("gaps.anyone"), biz.name].join(" · ");
|
|
167
184
|
let emailed = 0;
|
|
168
185
|
let failed = false;
|
|
169
|
-
for (const person of staff) {
|
|
170
|
-
const theirs = shifts.filter((s) => s.staff === person.id);
|
|
171
|
-
const last = before.get(person.id);
|
|
172
|
-
if (!theirs.length && !last)
|
|
173
|
-
continue;
|
|
174
|
-
const digest = await digestOf(theirs);
|
|
175
|
-
if (last?.digest === digest)
|
|
176
|
-
continue;
|
|
186
|
+
for (const { person, theirs, last, digest } of await toEmail(shifts, staff, sent ?? [])) {
|
|
177
187
|
const ids = new Set(theirs.map((s) => s.id));
|
|
178
188
|
const gone = (last?.lines ?? []).filter((l) => !ids.has(l.id));
|
|
179
189
|
const changed = !!last;
|
|
@@ -221,7 +231,7 @@ export function createRoster(opts) {
|
|
|
221
231
|
async function leaveIn(account, from, to, staff) {
|
|
222
232
|
return (await q("leave", "roster_leave_list", { p_account: account, p_from: from.toISOString(), p_to: to.toISOString(), p_staff: staff })).map(normLeave);
|
|
223
233
|
}
|
|
224
|
-
async function weekView(account, w) {
|
|
234
|
+
async function weekView(account, w, count = false) {
|
|
225
235
|
const a = text(account, "account", 200);
|
|
226
236
|
const week = weekArg(w);
|
|
227
237
|
const start = localInstant(week, "00:00", tz);
|
|
@@ -232,7 +242,39 @@ export function createRoster(opts) {
|
|
|
232
242
|
leaveIn(a, start, new Date(end.getTime() + DAY), null),
|
|
233
243
|
staffList(a, true),
|
|
234
244
|
]);
|
|
235
|
-
|
|
245
|
+
const view = { ...normWeek(state, week), days: days(week), shifts: shifts.map(normShift), leave, staff };
|
|
246
|
+
if (!count)
|
|
247
|
+
return view;
|
|
248
|
+
// Who Publish or Send the changes would email now, for its "Are you sure?".
|
|
249
|
+
if (!opts.mailer)
|
|
250
|
+
return { ...view, emailing: 0 };
|
|
251
|
+
if (view.status === "published" && !view.unsent)
|
|
252
|
+
return view;
|
|
253
|
+
const sent = (await q("week", "roster_sent_list", { p_account: a, p_week: week })) ?? [];
|
|
254
|
+
return { ...view, emailing: (await toEmail(view.shifts, staff, sent)).length };
|
|
255
|
+
}
|
|
256
|
+
/** The line a removed shift or a stretch of leave is in an email. */
|
|
257
|
+
const leaveText = (l) => ({ from: dateText(todayIn(tz, new Date(l.starts_at)), locale), to: dateText(todayIn(tz, new Date(Date.parse(l.ends_at) - 1)), locale) });
|
|
258
|
+
/** A notice email to one person; a failed email never fails what the owner did. */
|
|
259
|
+
async function notify(account, person, kind, key, params, lines, attachments = []) {
|
|
260
|
+
if (!opts.mailer)
|
|
261
|
+
return;
|
|
262
|
+
try {
|
|
263
|
+
const biz = await business(account);
|
|
264
|
+
const p = { ...params, name: person.name, business: biz.name };
|
|
265
|
+
await opts.mailer.send({
|
|
266
|
+
to: person.email,
|
|
267
|
+
subject: say(`email.${kind}.subject`, p),
|
|
268
|
+
text: [say("email.hello", p), "", say(`email.${kind}.body`, p), ...(lines.length ? ["", ...lines] : []), "", say(`email.${kind}.next`, p), "", say("email.footer", p)].join("\n"),
|
|
269
|
+
template: `roster.${kind}`,
|
|
270
|
+
...(biz.replyTo ? { replyTo: biz.replyTo } : {}),
|
|
271
|
+
...(attachments.length ? { attachments } : {}),
|
|
272
|
+
idempotencyKey: await mailKey(key, person.email),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
catch (e) {
|
|
276
|
+
report(e, `roster.${kind}`);
|
|
277
|
+
}
|
|
236
278
|
}
|
|
237
279
|
return {
|
|
238
280
|
config,
|
|
@@ -263,7 +305,22 @@ export function createRoster(opts) {
|
|
|
263
305
|
},
|
|
264
306
|
async removeStaff(account, id) {
|
|
265
307
|
const a = text(account, "account", 200);
|
|
266
|
-
const
|
|
308
|
+
const sid = idOf(id, "id");
|
|
309
|
+
const at = now();
|
|
310
|
+
// Who they are and the published shifts they lose, read first so the email can name them. A failed read never stops the removal.
|
|
311
|
+
const before = opts.mailer
|
|
312
|
+
? await Promise.all([
|
|
313
|
+
staffList(a, false).then((r) => r.find((s) => s.id === sid)),
|
|
314
|
+
q("removeStaff", "roster_shifts_list", { p_account: a, p_from: at.toISOString(), p_to: new Date(at.getTime() + 400 * DAY).toISOString(), p_staff: sid, p_published: true }).then((r) => (r ?? []).map(normShift)),
|
|
315
|
+
]).catch(() => null)
|
|
316
|
+
: null;
|
|
317
|
+
const done = await q("removeStaff", "roster_staff_remove", { p_account: a, p_id: sid, p_now: at.toISOString() });
|
|
318
|
+
const person = before?.[0];
|
|
319
|
+
if (done && person) {
|
|
320
|
+
const gone = before[1];
|
|
321
|
+
const files = gone.length ? [{ filename: "cancelled.ics", mimeType: "text/calendar", bytes: new TextEncoder().encode(cancelIcs(gone, say("ics.cancelled"), at)) }] : [];
|
|
322
|
+
await notify(a, person, "removed", `removed:${sid}:${at.toISOString()}`, {}, gone.map((g) => say("email.gone", { when: spanText(g.starts_at, g.ends_at, tz, locale) })), files);
|
|
323
|
+
}
|
|
267
324
|
return done;
|
|
268
325
|
},
|
|
269
326
|
async sendLink(account, id) {
|
|
@@ -293,7 +350,7 @@ export function createRoster(opts) {
|
|
|
293
350
|
return { token, emailed: 0 };
|
|
294
351
|
}
|
|
295
352
|
},
|
|
296
|
-
week: weekView,
|
|
353
|
+
week: (account, w) => weekView(account, w, true),
|
|
297
354
|
async addShift(account, input) {
|
|
298
355
|
const s = await q("addShift", "roster_shift_save", { ...shiftArgs(account, input), p_id: null });
|
|
299
356
|
return normShift(s);
|
|
@@ -351,7 +408,19 @@ export function createRoster(opts) {
|
|
|
351
408
|
return { leave: normLeave(l), clashes: theirs.filter((s) => Date.parse(s.ends_at) > start.getTime() && Date.parse(s.starts_at) < end.getTime()) };
|
|
352
409
|
},
|
|
353
410
|
async removeLeave(account, id) {
|
|
354
|
-
|
|
411
|
+
const a = text(account, "account", 200);
|
|
412
|
+
const lid = idOf(id, "id");
|
|
413
|
+
const at = now();
|
|
414
|
+
// The leave and its person, read first so the email can say which days. A failed read never stops the removal.
|
|
415
|
+
const before = opts.mailer
|
|
416
|
+
? await Promise.all([leaveIn(a, new Date(at.getTime() - 400 * DAY), new Date(at.getTime() + 3 * 366 * DAY), null).then((r) => r.find((l) => l.id === lid)), staffList(a, false)]).catch(() => null)
|
|
417
|
+
: null;
|
|
418
|
+
const done = await q("removeLeave", "roster_leave_remove", { p_account: a, p_id: lid });
|
|
419
|
+
const leave = before?.[0];
|
|
420
|
+
const person = leave ? before[1].find((s) => s.id === leave.staff) : undefined;
|
|
421
|
+
if (done && leave && person)
|
|
422
|
+
await notify(a, person, "leave_removed", `leave-removed:${lid}`, leaveText(leave), []);
|
|
423
|
+
return done;
|
|
355
424
|
},
|
|
356
425
|
async leave(account, o = {}) {
|
|
357
426
|
const a = text(account, "account", 200);
|
package/dist/styles.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// by the same names. `npx workbench-ui styles` writes these into the
|
|
6
6
|
// project's public/styles/workbench.css inside `@layer workbench`. The names
|
|
7
7
|
// are public: renaming one is a breaking change.
|
|
8
|
+
import { confirmStyles } from "./confirm.js";
|
|
8
9
|
const v = (name) => `var(--wb-roster-${name})`;
|
|
9
10
|
const focus = { selector: ":focus-visible", about: "Has focus", css: `outline:none;box-shadow:0 0 0 3px ${v("focus")}` };
|
|
10
11
|
const button = `display:inline-flex;align-items:center;justify-content:center;min-height:2.75rem;padding:0 1rem;font:inherit;font-weight:600;border-radius:${v("radius")};cursor:pointer;text-decoration:none`;
|
|
@@ -30,7 +31,7 @@ export const ROSTER_STYLES = {
|
|
|
30
31
|
{ name: "--wb-roster-on-accent", value: "#ffffff", about: "Text on a main button" },
|
|
31
32
|
{ name: "--wb-roster-good", value: "#3fb27f", about: "Published, every time covered, a done message" },
|
|
32
33
|
{ name: "--wb-roster-warn", value: "#f5a524", about: "A draft week, a gap, unsent changes, a person on leave" },
|
|
33
|
-
{ name: "--wb-roster-danger", value: "#e5484d", about: "Take off the roster" },
|
|
34
|
+
{ name: "--wb-roster-danger", value: "#e5484d", about: "Take off the roster, and the button that does it after \"Are you sure?\"" },
|
|
34
35
|
{ name: "--wb-roster-focus", value: "rgba(76,141,255,.4)", about: "The ring round a control with focus" },
|
|
35
36
|
{ name: "--wb-roster-radius", value: "8px", about: "Corner rounding" },
|
|
36
37
|
],
|
|
@@ -69,8 +70,8 @@ export const ROSTER_STYLES = {
|
|
|
69
70
|
{ name: "wb-roster-break", element: "span", about: "The unpaid break", css: small },
|
|
70
71
|
{ name: "wb-roster-note", element: "span", about: "The owner's note: Open up", css: `${small};font-style:italic;overflow-wrap:anywhere` },
|
|
71
72
|
{ name: "wb-roster-flag", element: "span", about: "On leave, no longer on the roster, has their link", css: `font-size:.85rem;font-weight:600;color:${v("warn")}` },
|
|
72
|
-
{ name: "wb-roster-inline", element: "form", about: "A form that is only a button: Remove,
|
|
73
|
-
{ name: "wb-roster-remove", element: "button", about: "Remove a shift or leave", css: `${quiet};min-height:2.75rem;padding:0 .75rem;font-weight:400`, states: [focus] },
|
|
73
|
+
{ name: "wb-roster-inline", element: "form", about: "A form that is only a button: Remove a shift from a draft week, Copy last week", css: "display:inline-flex;margin:0" },
|
|
74
|
+
{ name: "wb-roster-remove", element: "button", about: "Remove a shift or leave (on a <summary> where it asks \"Are you sure?\" first)", css: `${quiet};min-height:2.75rem;padding:0 .75rem;font-weight:400`, states: [focus] },
|
|
74
75
|
{ name: "wb-roster-empty", element: "p", about: "No shifts, no leave, nobody yet", css: `margin:0;color:${v("muted")}` },
|
|
75
76
|
{ name: "wb-roster-form", element: "form", about: "Add a shift, Add leave, Add person", css: `display:grid;gap:.75rem;padding:.75rem;background:${v("surface")};border:1px solid ${v("line")};border-radius:${v("radius")}` },
|
|
76
77
|
{ name: "wb-roster-field", element: "div", about: "One field: its label and input", css: "display:grid;gap:.25rem" },
|
|
@@ -80,20 +81,21 @@ export const ROSTER_STYLES = {
|
|
|
80
81
|
{ name: "wb-roster-input", element: "input", about: "Times, dates, the break, the note, name and email", css: input, states: [focus] },
|
|
81
82
|
{ name: "wb-roster-button", element: "button", about: "Add shift, Add person", css: `${main};justify-self:start`, states: [focus] },
|
|
82
83
|
{ name: "wb-roster-actions", element: "div", about: "Publish, Copy last week, Download hours", css: "display:flex;flex-wrap:wrap;gap:.5rem" },
|
|
83
|
-
{ name: "wb-roster-publish", element: "
|
|
84
|
-
{ name: "wb-roster-secondary", element: "button", about: "Copy last week, Add leave, Email them their link", css: quiet, states: [focus] },
|
|
84
|
+
{ name: "wb-roster-publish", element: "summary", about: "Publish and email staff, or Send the changes now: opens \"Are you sure?\"", css: main, states: [focus] },
|
|
85
|
+
{ name: "wb-roster-secondary", element: "button", about: "Copy last week, Add leave, and Email them their link (a <summary> that opens \"Are you sure?\")", css: quiet, states: [focus] },
|
|
85
86
|
{ name: "wb-roster-export", element: "a", about: "Download hours", css: quiet, states: [focus] },
|
|
86
87
|
{ name: "wb-roster-people", element: "ul", about: "The people on the roster", css: "list-style:none;margin:0;padding:0;display:grid;gap:.75rem" },
|
|
87
88
|
{ name: "wb-roster-person", element: "li", about: "One person, their leave and their buttons", css: `display:grid;gap:.5rem;padding:.75rem;background:${v("surface")};border:1px solid ${v("line")};border-radius:${v("radius")}` },
|
|
88
89
|
{ name: "wb-roster-detail", element: "span", about: "Email, roles and bookings name", css: `${small};overflow-wrap:anywhere` },
|
|
89
90
|
{ name: "wb-roster-leave-list", element: "ul", about: "A person's leave", css: "list-style:none;margin:0;padding:0;display:grid;gap:.25rem" },
|
|
90
91
|
{ name: "wb-roster-leave", element: "li", about: "One stretch of leave", css: "display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;justify-content:space-between" },
|
|
91
|
-
{ name: "wb-roster-remove-form", element: "
|
|
92
|
-
{ name: "wb-roster-
|
|
93
|
-
{ name: "wb-roster-check", element: "input", about: "A tick box: a role
|
|
94
|
-
{ name: "wb-roster-danger", element: "
|
|
92
|
+
{ name: "wb-roster-remove-form", element: "div", about: "Take off the roster: asks \"Are you sure?\" first", css: `display:grid;gap:.5rem;padding:.75rem;border:1px solid ${v("danger")};border-radius:${v("radius")}` },
|
|
93
|
+
{ name: "wb-roster-tick", element: "label", about: "A tick box and its words: a role a new person can work", css: "display:flex;gap:.5rem;align-items:center;min-height:2.75rem" },
|
|
94
|
+
{ name: "wb-roster-check", element: "input", about: "A tick box: a role", css: `width:1.25rem;height:1.25rem;accent-color:${v("accent")}`, states: [focus] },
|
|
95
|
+
{ name: "wb-roster-danger", element: "summary", about: "Take off the roster: opens \"Are you sure?\"", css: `${button};justify-self:start;color:${v("on-accent")};background:${v("danger")};border:1px solid ${v("danger")}`, states: [focus] },
|
|
95
96
|
{ name: "wb-roster-roles", element: "fieldset", about: "The roles a new person can work", css: "display:grid;gap:.25rem;margin:0;padding:0;border:0" },
|
|
96
97
|
{ name: "wb-roster-hint", element: "p", about: "What a field is for; this page is yours", css: `margin:0;${small}` },
|
|
97
98
|
{ name: "wb-roster-calendar", element: "a", about: "Add my shifts to my calendar", css: `${main};justify-self:start`, states: [focus] },
|
|
99
|
+
...confirmStyles("wb-roster", (n) => v(n === "on-danger" ? "on-accent" : n), { reason: false }),
|
|
98
100
|
],
|
|
99
101
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -114,6 +114,8 @@ export interface WeekView extends WeekState {
|
|
|
114
114
|
shifts: Shift[];
|
|
115
115
|
leave: Leave[];
|
|
116
116
|
staff: Staff[];
|
|
117
|
+
/** How many people Publish (or Send the changes) would email now, for its "Are you sure?". Left out when the view didn't count them. */
|
|
118
|
+
emailing?: number;
|
|
117
119
|
}
|
|
118
120
|
/** A time the cover rules (or a session the app passes) aren't met. */
|
|
119
121
|
export interface Gap {
|
package/dist/ui.d.ts
CHANGED
|
@@ -68,10 +68,13 @@ export interface ActionResult {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* The project's endpoint (behind the owner's sign-in) hands the posted form
|
|
71
|
-
* fields here with the signed-in owner's account: add_shift, remove_shift
|
|
72
|
-
*
|
|
73
|
-
* confirm=yes),
|
|
74
|
-
*
|
|
71
|
+
* fields here with the signed-in owner's account: add_shift, remove_shift
|
|
72
|
+
* (needs confirm=yes when the shift is in a published week), publish (also
|
|
73
|
+
* Send changes; needs confirm=yes), copy_week, save_staff, remove_staff
|
|
74
|
+
* (needs confirm=yes), send_link (needs confirm=yes), add_leave and
|
|
75
|
+
* remove_leave (needs confirm=yes). Without it they are refused with
|
|
76
|
+
* `confirm_needed` (409) and nothing changes. Another account's shift or
|
|
77
|
+
* person is answered as unknown.
|
|
75
78
|
*/
|
|
76
79
|
export declare function rosterAction(roster: Roster, body: Record<string, unknown>, account: string): Promise<ActionResult>;
|
|
77
80
|
export {};
|
package/dist/ui.js
CHANGED
|
@@ -3,15 +3,22 @@
|
|
|
3
3
|
// to the project's endpoint (behind the owner's sign-in), which hands the
|
|
4
4
|
// fields to rosterAction with the signed-in owner's account. Every element
|
|
5
5
|
// carries a wb-roster-* class (ROSTER_STYLES), and every control is at least
|
|
6
|
-
// 44 px tall. Taking someone off the roster
|
|
6
|
+
// 44 px tall. Taking someone off the roster, removing leave, emailing a new
|
|
7
|
+
// link, publishing and removing a shift from a published week ask "Are you
|
|
8
|
+
// sure?" first (renderConfirm), and rosterAction refuses them without
|
|
9
|
+
// confirm=yes.
|
|
10
|
+
import { confirmed, renderConfirm } from "./confirm.js";
|
|
7
11
|
import { RosterError } from "./errors.js";
|
|
8
12
|
import { dayText, localeFor, spanText, timeText, words } from "./format.js";
|
|
9
13
|
import { addDays, clockMinutes, todayIn } from "./time.js";
|
|
14
|
+
import { ROSTER_WORDS } from "./words.js";
|
|
10
15
|
const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
11
16
|
const ctx = (o) => ({ say: words(o), locale: localeFor(o.lang, o.locale), tz: o.config.time_zone });
|
|
12
17
|
const roleTitle = (o, r) => (r ? (o.config.roles?.[r]?.title ?? r) : null);
|
|
13
18
|
const hidden = (fields) => Object.entries(fields).map(([k, v]) => `<input type="hidden" name="${k}" value="${esc(v)}">`).join("");
|
|
14
19
|
const leaveDays = (l, tz) => ({ from: todayIn(tz, new Date(l.starts_at)), to: todayIn(tz, new Date(Date.parse(l.ends_at) - 1)) });
|
|
20
|
+
/** A button that asks "Are you sure?" first, with the roster's class names. */
|
|
21
|
+
const ask = (c, endpoint, fields, o) => renderConfirm({ prefix: "wb-roster", endpoint, fields, ask: o.ask, askClass: o.askClass, question: o.question, consequence: o.consequence, yes: o.yes, no: o.no ?? c.say("confirm.no") });
|
|
15
22
|
function shiftParts(s, o, c, withName) {
|
|
16
23
|
const role = roleTitle(o, s.role);
|
|
17
24
|
return [
|
|
@@ -29,6 +36,25 @@ function gapText(g, o, c) {
|
|
|
29
36
|
}
|
|
30
37
|
const field = (id, label, control) => `<div class="wb-roster-field"><label class="wb-roster-label" for="${id}">${esc(label)}</label>${control}</div>`;
|
|
31
38
|
const option = (value, label, selected = false) => `<option class="wb-roster-option" value="${esc(value)}"${selected ? " selected" : ""}>${esc(label)}</option>`;
|
|
39
|
+
/** Publish, or Send the changes: asks first, saying how many people get the email. */
|
|
40
|
+
function publishAsk(v, o, c) {
|
|
41
|
+
const first = v.status === "draft";
|
|
42
|
+
const date = dayText(v.week, c.locale);
|
|
43
|
+
const n = v.emailing;
|
|
44
|
+
const consequence = n === undefined
|
|
45
|
+
? c.say(first ? "week.publish.consequence_all" : "week.send.consequence_all")
|
|
46
|
+
: n === 0
|
|
47
|
+
? c.say(first ? "week.publish.consequence_none" : "week.send.consequence_none")
|
|
48
|
+
: c.say(n === 1 ? (first ? "week.publish.consequence_one" : "week.send.consequence_one") : first ? "week.publish.consequence" : "week.send.consequence", { count: n });
|
|
49
|
+
return ask(c, o.endpoint, { action: "publish", week: v.week }, {
|
|
50
|
+
ask: c.say(first ? "week.publish" : "week.send"),
|
|
51
|
+
askClass: "wb-roster-publish",
|
|
52
|
+
question: c.say(first ? "week.publish.question" : "week.send.question", { date }),
|
|
53
|
+
consequence,
|
|
54
|
+
yes: c.say(first ? "week.publish.yes" : "week.send.yes"),
|
|
55
|
+
no: c.say("week.publish.no"),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
32
58
|
/** The owner's week: its state, Last and Next week, the gaps, each day's shifts with Remove, Add a shift, Publish or Send changes, Copy last week and Download hours. */
|
|
33
59
|
export function renderWeek(v, o) {
|
|
34
60
|
const c = ctx(o);
|
|
@@ -52,7 +78,13 @@ export function renderWeek(v, o) {
|
|
|
52
78
|
? `<ul class="wb-roster-shifts">${shifts
|
|
53
79
|
.map((s) => {
|
|
54
80
|
const flag = flagged.get(s.id);
|
|
55
|
-
|
|
81
|
+
// On a published week the person has been told about this shift, so taking it off asks first.
|
|
82
|
+
const p = { name: s.staff_name, when: spanText(s.starts_at, s.ends_at, c.tz, c.locale) };
|
|
83
|
+
const told = v.staff.some((x) => x.id === s.staff && x.active);
|
|
84
|
+
const remove = v.status === "published"
|
|
85
|
+
? ask(c, o.endpoint, { action: "remove_shift", shift: s.id, week: v.week }, { ask: c.say("shift.remove"), askClass: "wb-roster-remove", question: c.say("shift.remove.question", p), consequence: c.say(!told ? "shift.remove.consequence_gone" : o.config.changes === "manual" ? "shift.remove.consequence_manual" : "shift.remove.consequence", p), yes: c.say("shift.remove.yes") })
|
|
86
|
+
: `<form class="wb-roster-inline" method="post" action="${esc(o.endpoint)}">${hidden({ action: "remove_shift", shift: s.id, week: v.week })}<button class="wb-roster-remove" type="submit">${esc(c.say("shift.remove"))}</button></form>`;
|
|
87
|
+
return `<li class="wb-roster-shift">${shiftParts(s, o, c, true)}${flag ? `<span class="wb-roster-flag">${esc(c.say(flag === "on_leave" ? "shift.on_leave" : "shift.removed"))}</span>` : ""}${remove}</li>`;
|
|
56
88
|
})
|
|
57
89
|
.join("")}</ul>`
|
|
58
90
|
: `<p class="wb-roster-empty">${esc(c.say("week.none"))}</p>`;
|
|
@@ -65,7 +97,7 @@ export function renderWeek(v, o) {
|
|
|
65
97
|
? `<form class="wb-roster-form" method="post" action="${esc(o.endpoint)}">${hidden({ action: "add_shift", week: v.week })}<h3 class="wb-roster-heading">${esc(c.say("add.title"))}</h3>${field("wb-roster-staff", c.say("add.person"), `<select class="wb-roster-select" id="wb-roster-staff" name="staff" required>${active.map((s) => option(s.id, s.name)).join("")}</select>`)}${field("wb-roster-on", c.say("add.day"), `<select class="wb-roster-select" id="wb-roster-on" name="day" required>${v.days.map((d) => option(d, dayText(d, c.locale))).join("")}</select>`)}${field("wb-roster-start", c.say("add.start"), `<input class="wb-roster-input" id="wb-roster-start" type="time" name="start" required>`)}${field("wb-roster-end", c.say("add.end"), `<input class="wb-roster-input" id="wb-roster-end" type="time" name="end" required>`)}${roles.length ? field("wb-roster-role", c.say("add.role"), `<select class="wb-roster-select" id="wb-roster-role" name="role">${option("", c.say("add.role_any"))}${roles.map(([k, r]) => option(k, r.title)).join("")}</select>`) : ""}${field("wb-roster-break", c.say("add.break"), `<input class="wb-roster-input" id="wb-roster-break" type="number" name="break" min="0" max="240" step="5" value="0" inputmode="numeric">`)}${field("wb-roster-note", c.say("add.note"), `<input class="wb-roster-input" id="wb-roster-note" type="text" name="note" maxlength="200" autocomplete="off">`)}<button class="wb-roster-button" type="submit">${esc(c.say("add.button"))}</button></form>`
|
|
66
98
|
: "";
|
|
67
99
|
const actions = [
|
|
68
|
-
v.status === "draft" || v.unsent ?
|
|
100
|
+
v.status === "draft" || v.unsent ? publishAsk(v, o, c) : "",
|
|
69
101
|
v.shifts.length === 0 ? `<form class="wb-roster-inline" method="post" action="${esc(o.endpoint)}">${hidden({ action: "copy_week", week: v.week })}<button class="wb-roster-secondary" type="submit">${esc(c.say("week.copy"))}</button></form>` : "",
|
|
70
102
|
o.exportUrl ? `<a class="wb-roster-export" href="${esc(o.exportUrl)}" download>${esc(c.say("week.export"))}</a>` : "",
|
|
71
103
|
].join("");
|
|
@@ -86,20 +118,22 @@ export function renderStaff(staff, o) {
|
|
|
86
118
|
? `<ul class="wb-roster-leave-list">${theirs
|
|
87
119
|
.map((l) => {
|
|
88
120
|
const d = leaveDays(l, c.tz);
|
|
89
|
-
|
|
121
|
+
const p = { name: s.name, from: dayText(d.from, c.locale), to: dayText(d.to, c.locale) };
|
|
122
|
+
return `<li class="wb-roster-leave"><span class="wb-roster-time">${esc(c.say("leave.when", p))}</span>${ask(c, o.endpoint, { action: "remove_leave", leave: l.id }, { ask: c.say("leave.remove"), askClass: "wb-roster-remove", question: c.say("leave.remove.question", p), consequence: c.say("leave.remove.consequence", p), yes: c.say("leave.remove.yes") })}</li>`;
|
|
90
123
|
})
|
|
91
124
|
.join("")}</ul>`
|
|
92
125
|
: `<p class="wb-roster-empty">${esc(c.say("leave.none"))}</p>`;
|
|
93
126
|
const id = `wb-roster-${s.id.slice(0, 8)}`;
|
|
94
127
|
const leaveForm = `<form class="wb-roster-form" method="post" action="${esc(o.endpoint)}">${hidden({ action: "add_leave", staff: s.id })}${field(`${id}-from`, c.say("leave.from"), `<input class="wb-roster-input" id="${id}-from" type="date" name="from" required>`)}${field(`${id}-to`, c.say("leave.to"), `<input class="wb-roster-input" id="${id}-to" type="date" name="to" required>`)}<button class="wb-roster-secondary" type="submit">${esc(c.say("leave.add"))}</button></form>`;
|
|
95
|
-
const
|
|
96
|
-
const
|
|
128
|
+
const p = { name: s.name };
|
|
129
|
+
const link = ask(c, o.endpoint, { action: "send_link", staff: s.id }, { ask: c.say("staff.link"), askClass: "wb-roster-secondary", question: c.say("staff.link.question", p), consequence: c.say(s.has_link ? "staff.link.consequence" : "staff.link.consequence_first", p), yes: c.say("staff.link.yes"), no: c.say("staff.link.no") });
|
|
130
|
+
const remove = `<div class="wb-roster-remove-form">${ask(c, o.endpoint, { action: "remove_staff", staff: s.id }, { ask: c.say("staff.remove"), askClass: "wb-roster-danger", question: c.say("staff.remove.question", p), consequence: c.say("staff.remove.consequence", p), yes: c.say("staff.remove.yes", p), no: c.say("staff.remove.no") })}</div>`;
|
|
97
131
|
return `<li class="wb-roster-person"><span class="wb-roster-who">${esc(s.name)}</span><span class="wb-roster-detail">${esc(detail)}</span><span class="wb-roster-flag">${esc(c.say(s.has_link ? "staff.link_sent" : "staff.no_link"))}</span><h3 class="wb-roster-heading">${esc(c.say("leave.title"))}</h3>${leave}${leaveForm}${link}${remove}</li>`;
|
|
98
132
|
})
|
|
99
133
|
.join("")}</ul>`
|
|
100
134
|
: `<p class="wb-roster-empty">${esc(c.say("staff.empty"))}</p>`;
|
|
101
135
|
const roleBoxes = roles.length
|
|
102
|
-
? `<fieldset class="wb-roster-roles"><legend class="wb-roster-label">${esc(c.say("staff.roles"))}</legend>${roles.map(([k, r]) => `<label class="wb-roster-
|
|
136
|
+
? `<fieldset class="wb-roster-roles"><legend class="wb-roster-label">${esc(c.say("staff.roles"))}</legend>${roles.map(([k, r]) => `<label class="wb-roster-tick"><input class="wb-roster-check" type="checkbox" name="roles" value="${esc(k)}"> ${esc(r.title)}</label>`).join("")}</fieldset>`
|
|
103
137
|
: "";
|
|
104
138
|
const add = `<form class="wb-roster-form" method="post" action="${esc(o.endpoint)}">${hidden({ action: "save_staff" })}<h3 class="wb-roster-heading">${esc(c.say("staff.add"))}</h3>${field("wb-roster-name", c.say("staff.name"), `<input class="wb-roster-input" id="wb-roster-name" type="text" name="name" maxlength="100" required autocomplete="off">`)}${field("wb-roster-email", c.say("staff.email"), `<input class="wb-roster-input" id="wb-roster-email" type="email" name="email" maxlength="254" required autocomplete="off">`)}${roleBoxes}${field("wb-roster-resource", c.say("staff.resource"), `<input class="wb-roster-input" id="wb-roster-resource" type="text" name="resource" maxlength="40" pattern="[a-z0-9][a-z0-9\\-]*" autocomplete="off">`)}<p class="wb-roster-hint">${esc(c.say("staff.resource_hint"))}</p><button class="wb-roster-button" type="submit">${esc(c.say("staff.add"))}</button></form>`;
|
|
105
139
|
return `<section class="wb-roster-staff"><h2 class="wb-roster-title">${esc(c.say("staff.title"))}</h2>${done}${people}${add}</section>`;
|
|
@@ -119,16 +153,30 @@ export function renderMyShifts(v, o) {
|
|
|
119
153
|
const calendar = o.feedUrl ? `<a class="wb-roster-calendar" href="${esc(o.feedUrl)}">${esc(c.say("mine.calendar"))}</a>` : "";
|
|
120
154
|
return `<article class="wb-roster-mine"><h2 class="wb-roster-title">${esc(c.say("mine.title", { name: v.staff.name }))}</h2>${shifts}${leave}${calendar}<p class="wb-roster-hint">${esc(c.say("mine.private"))}</p></article>`;
|
|
121
155
|
}
|
|
156
|
+
/** These can't be undone, so the post must carry the answer to "Are you sure?" (confirm=yes, which renderConfirm's button sends). */
|
|
157
|
+
function needConfirm() {
|
|
158
|
+
throw new RosterError("confirm_needed", ROSTER_WORDS.en["error.confirm_needed"]);
|
|
159
|
+
}
|
|
160
|
+
/** Whether a shift is in a week that isn't published yet (staff haven't seen it). A shift not found in that week asks first. */
|
|
161
|
+
async function inDraft(roster, account, week, shift) {
|
|
162
|
+
if (!week)
|
|
163
|
+
return false;
|
|
164
|
+
const v = await roster.week(account, week);
|
|
165
|
+
return v.status === "draft" && v.shifts.some((s) => s.id === shift);
|
|
166
|
+
}
|
|
122
167
|
const field1 = (body, k) => {
|
|
123
168
|
const v = body[k];
|
|
124
169
|
return typeof v === "string" ? v.trim() : "";
|
|
125
170
|
};
|
|
126
171
|
/**
|
|
127
172
|
* The project's endpoint (behind the owner's sign-in) hands the posted form
|
|
128
|
-
* fields here with the signed-in owner's account: add_shift, remove_shift
|
|
129
|
-
*
|
|
130
|
-
* confirm=yes),
|
|
131
|
-
*
|
|
173
|
+
* fields here with the signed-in owner's account: add_shift, remove_shift
|
|
174
|
+
* (needs confirm=yes when the shift is in a published week), publish (also
|
|
175
|
+
* Send changes; needs confirm=yes), copy_week, save_staff, remove_staff
|
|
176
|
+
* (needs confirm=yes), send_link (needs confirm=yes), add_leave and
|
|
177
|
+
* remove_leave (needs confirm=yes). Without it they are refused with
|
|
178
|
+
* `confirm_needed` (409) and nothing changes. Another account's shift or
|
|
179
|
+
* person is answered as unknown.
|
|
132
180
|
*/
|
|
133
181
|
export async function rosterAction(roster, body, account) {
|
|
134
182
|
try {
|
|
@@ -148,10 +196,15 @@ export async function rosterAction(roster, body, account) {
|
|
|
148
196
|
return { status: 200, body: { ok: true, action, done: "add_shift", week: s.week } };
|
|
149
197
|
}
|
|
150
198
|
case "remove_shift":
|
|
199
|
+
// A shift in a draft week is one click; one staff have been told about asks first.
|
|
200
|
+
if (!confirmed(body) && !(await inDraft(roster, account, week, field1(body, "shift"))))
|
|
201
|
+
needConfirm();
|
|
151
202
|
if (!(await roster.removeShift(account, field1(body, "shift"))))
|
|
152
203
|
throw new RosterError("unknown_shift", "no such shift");
|
|
153
204
|
return { status: 200, body: { ok: true, action, done: "remove_shift", ...(week ? { week } : {}) } };
|
|
154
205
|
case "publish": {
|
|
206
|
+
if (!confirmed(body))
|
|
207
|
+
needConfirm();
|
|
155
208
|
const r = await roster.publish(account, week);
|
|
156
209
|
return { status: 200, body: { ok: true, action, done: "publish", week: r.week.week, emailed: r.emailed } };
|
|
157
210
|
}
|
|
@@ -167,12 +220,14 @@ export async function rosterAction(roster, body, account) {
|
|
|
167
220
|
return { status: 200, body: { ok: true, action, done: "save_staff" } };
|
|
168
221
|
}
|
|
169
222
|
case "remove_staff":
|
|
170
|
-
if (body
|
|
171
|
-
|
|
223
|
+
if (!confirmed(body))
|
|
224
|
+
needConfirm();
|
|
172
225
|
if (!(await roster.removeStaff(account, field1(body, "staff"))))
|
|
173
226
|
throw new RosterError("unknown_staff", "no such person on the roster");
|
|
174
227
|
return { status: 200, body: { ok: true, action, done: "remove_staff" } };
|
|
175
228
|
case "send_link": {
|
|
229
|
+
if (!confirmed(body))
|
|
230
|
+
needConfirm();
|
|
176
231
|
const r = await roster.sendLink(account, field1(body, "staff"));
|
|
177
232
|
return { status: 200, body: { ok: true, action, done: "send_link", emailed: r.emailed } };
|
|
178
233
|
}
|
|
@@ -180,6 +235,8 @@ export async function rosterAction(roster, body, account) {
|
|
|
180
235
|
await roster.addLeave(account, { staff: field1(body, "staff"), from: field1(body, "from"), to: field1(body, "to") });
|
|
181
236
|
return { status: 200, body: { ok: true, action, done: "add_leave" } };
|
|
182
237
|
case "remove_leave":
|
|
238
|
+
if (!confirmed(body))
|
|
239
|
+
needConfirm();
|
|
183
240
|
if (!(await roster.removeLeave(account, field1(body, "leave"))))
|
|
184
241
|
throw new RosterError("unknown_shift", "no such leave");
|
|
185
242
|
return { status: 200, body: { ok: true, action, done: "remove_leave" } };
|
|
@@ -189,7 +246,7 @@ export async function rosterAction(roster, body, account) {
|
|
|
189
246
|
}
|
|
190
247
|
catch (e) {
|
|
191
248
|
if (e instanceof RosterError) {
|
|
192
|
-
const status = e.code === "unknown_staff" || e.code === "unknown_shift" ? 404 : e.code === "clash" || e.code === "on_leave" || e.code === "taken" || e.code === "not_empty" ? 409 : e.code === "store_failed" ? 502 : e.code === "bad_config" ? 500 : 400;
|
|
249
|
+
const status = e.code === "unknown_staff" || e.code === "unknown_shift" ? 404 : e.code === "clash" || e.code === "on_leave" || e.code === "taken" || e.code === "not_empty" || e.code === "confirm_needed" ? 409 : e.code === "store_failed" ? 502 : e.code === "bad_config" ? 500 : 400;
|
|
193
250
|
const message = e.code === "store_failed" || e.code === "bad_config" ? "roster: it failed on the app's side (the detail is in the result's cause, for the log)" : e.message;
|
|
194
251
|
return { status, body: { ok: false, error: e.code, message }, cause: e };
|
|
195
252
|
}
|
package/dist/words.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const ROSTER_WORD_KEYS: readonly ["week.title", "week.draft", "week.published", "week.unsent", "week.prev", "week.next", "week.none", "week.publish", "week.send", "week.copy", "week.export", "shift.break", "shift.remove", "shift.on_leave", "shift.removed", "add.title", "add.person", "add.day", "add.start", "add.end", "add.role", "add.role_any", "add.break", "add.note", "add.button", "gaps.title", "gaps.none", "gaps.nobody", "gaps.short", "gaps.anyone", "staff.title", "staff.empty", "staff.name", "staff.email", "staff.roles", "staff.resource", "staff.resource_hint", "staff.add", "staff.save", "staff.link", "staff.link_sent", "staff.no_link", "staff.remove", "
|
|
1
|
+
export declare const ROSTER_WORD_KEYS: readonly ["week.title", "week.draft", "week.published", "week.unsent", "week.prev", "week.next", "week.none", "week.publish", "week.send", "week.copy", "week.export", "shift.break", "shift.remove", "shift.on_leave", "shift.removed", "add.title", "add.person", "add.day", "add.start", "add.end", "add.role", "add.role_any", "add.break", "add.note", "add.button", "gaps.title", "gaps.none", "gaps.nobody", "gaps.short", "gaps.anyone", "staff.title", "staff.empty", "staff.name", "staff.email", "staff.roles", "staff.resource", "staff.resource_hint", "staff.add", "staff.save", "staff.link", "staff.link_sent", "staff.no_link", "staff.remove", "leave.title", "leave.none", "leave.from", "leave.to", "leave.add", "leave.remove", "leave.when", "mine.title", "mine.none", "mine.calendar", "mine.private", "mine.leave", "done.add_shift", "done.remove_shift", "done.publish", "done.copy", "done.save_staff", "done.remove_staff", "done.send_link", "done.add_leave", "done.remove_leave", "email.week.subject", "email.changed.subject", "email.hello", "email.week.intro", "email.changed.intro", "email.none", "email.gone", "email.calendar", "email.footer", "email.link.subject", "email.link.body", "email.link.feed", "email.link.keep", "ics.cancelled", "csv.date", "csv.name", "csv.role", "csv.start", "csv.end", "csv.break", "csv.hours", "confirm.no", "error.confirm_needed", "shift.remove.question", "shift.remove.consequence", "shift.remove.consequence_manual", "shift.remove.consequence_gone", "shift.remove.yes", "week.publish.question", "week.publish.consequence", "week.publish.consequence_one", "week.publish.consequence_none", "week.publish.consequence_all", "week.publish.yes", "week.publish.no", "week.send.question", "week.send.consequence", "week.send.consequence_one", "week.send.consequence_none", "week.send.consequence_all", "week.send.yes", "staff.link.question", "staff.link.consequence", "staff.link.consequence_first", "staff.link.yes", "staff.link.no", "staff.remove.question", "staff.remove.consequence", "staff.remove.yes", "staff.remove.no", "leave.remove.question", "leave.remove.consequence", "leave.remove.yes", "email.removed.subject", "email.removed.body", "email.removed.next", "email.leave_removed.subject", "email.leave_removed.body", "email.leave_removed.next"];
|
|
2
2
|
export type RosterWordKey = (typeof ROSTER_WORD_KEYS)[number];
|
|
3
3
|
export declare const ROSTER_WORDS: Readonly<Record<"en" | "tl" | "taglish", Readonly<Record<RosterWordKey, string>>>>;
|
package/dist/words.js
CHANGED
|
@@ -47,7 +47,6 @@ export const ROSTER_WORD_KEYS = [
|
|
|
47
47
|
"staff.link_sent",
|
|
48
48
|
"staff.no_link",
|
|
49
49
|
"staff.remove",
|
|
50
|
-
"staff.remove_confirm",
|
|
51
50
|
"leave.title",
|
|
52
51
|
"leave.none",
|
|
53
52
|
"leave.from",
|
|
@@ -90,6 +89,44 @@ export const ROSTER_WORD_KEYS = [
|
|
|
90
89
|
"csv.end",
|
|
91
90
|
"csv.break",
|
|
92
91
|
"csv.hours",
|
|
92
|
+
"confirm.no",
|
|
93
|
+
"error.confirm_needed",
|
|
94
|
+
"shift.remove.question",
|
|
95
|
+
"shift.remove.consequence",
|
|
96
|
+
"shift.remove.consequence_manual",
|
|
97
|
+
"shift.remove.consequence_gone",
|
|
98
|
+
"shift.remove.yes",
|
|
99
|
+
"week.publish.question",
|
|
100
|
+
"week.publish.consequence",
|
|
101
|
+
"week.publish.consequence_one",
|
|
102
|
+
"week.publish.consequence_none",
|
|
103
|
+
"week.publish.consequence_all",
|
|
104
|
+
"week.publish.yes",
|
|
105
|
+
"week.publish.no",
|
|
106
|
+
"week.send.question",
|
|
107
|
+
"week.send.consequence",
|
|
108
|
+
"week.send.consequence_one",
|
|
109
|
+
"week.send.consequence_none",
|
|
110
|
+
"week.send.consequence_all",
|
|
111
|
+
"week.send.yes",
|
|
112
|
+
"staff.link.question",
|
|
113
|
+
"staff.link.consequence",
|
|
114
|
+
"staff.link.consequence_first",
|
|
115
|
+
"staff.link.yes",
|
|
116
|
+
"staff.link.no",
|
|
117
|
+
"staff.remove.question",
|
|
118
|
+
"staff.remove.consequence",
|
|
119
|
+
"staff.remove.yes",
|
|
120
|
+
"staff.remove.no",
|
|
121
|
+
"leave.remove.question",
|
|
122
|
+
"leave.remove.consequence",
|
|
123
|
+
"leave.remove.yes",
|
|
124
|
+
"email.removed.subject",
|
|
125
|
+
"email.removed.body",
|
|
126
|
+
"email.removed.next",
|
|
127
|
+
"email.leave_removed.subject",
|
|
128
|
+
"email.leave_removed.body",
|
|
129
|
+
"email.leave_removed.next",
|
|
93
130
|
];
|
|
94
131
|
const en = {
|
|
95
132
|
"week.title": "Roster: week of {date}",
|
|
@@ -135,7 +172,6 @@ const en = {
|
|
|
135
172
|
"staff.link_sent": "Has their link",
|
|
136
173
|
"staff.no_link": "No link yet",
|
|
137
174
|
"staff.remove": "Take off the roster",
|
|
138
|
-
"staff.remove_confirm": "Yes, take them off. Their shifts from now on are removed.",
|
|
139
175
|
"leave.title": "Leave",
|
|
140
176
|
"leave.none": "No leave coming up.",
|
|
141
177
|
"leave.from": "First day away",
|
|
@@ -178,6 +214,44 @@ const en = {
|
|
|
178
214
|
"csv.end": "End",
|
|
179
215
|
"csv.break": "Break (minutes)",
|
|
180
216
|
"csv.hours": "Hours",
|
|
217
|
+
"confirm.no": "No, keep it",
|
|
218
|
+
"error.confirm_needed": "Please confirm first. Nothing has changed.",
|
|
219
|
+
"shift.remove.question": "Remove {name}'s shift on {when}?",
|
|
220
|
+
"shift.remove.consequence": "This week is published, so we'll email {name} to say this shift is off once you've stopped making changes. This can't be undone.",
|
|
221
|
+
"shift.remove.consequence_manual": "This week is published, so {name} is emailed that this shift is off when you send the changes. This can't be undone.",
|
|
222
|
+
"shift.remove.consequence_gone": "{name} is no longer on the roster, so nobody is emailed. This can't be undone.",
|
|
223
|
+
"shift.remove.yes": "Yes, remove this shift",
|
|
224
|
+
"week.publish.question": "Publish the week of {date}?",
|
|
225
|
+
"week.publish.consequence": "We'll email {count} people their shifts for the week, with a calendar file, and staff can see it on their own pages. Emails can't be taken back.",
|
|
226
|
+
"week.publish.consequence_one": "We'll email 1 person their shifts for the week, with a calendar file, and staff can see it on their own pages. Emails can't be taken back.",
|
|
227
|
+
"week.publish.consequence_none": "Nobody is emailed. Once it's published, staff can see the week on their own pages.",
|
|
228
|
+
"week.publish.consequence_all": "We'll email everyone with shifts that week, with a calendar file, and staff can see it on their own pages. Emails can't be taken back.",
|
|
229
|
+
"week.publish.yes": "Yes, publish and email",
|
|
230
|
+
"week.publish.no": "No, not yet",
|
|
231
|
+
"week.send.question": "Send the changes to the week of {date}?",
|
|
232
|
+
"week.send.consequence": "We'll email the {count} people whose shifts have changed. Emails can't be taken back.",
|
|
233
|
+
"week.send.consequence_one": "We'll email the 1 person whose shifts have changed. Emails can't be taken back.",
|
|
234
|
+
"week.send.consequence_none": "Nobody's shifts have changed since they were last emailed, so nobody is emailed.",
|
|
235
|
+
"week.send.consequence_all": "We'll email everyone whose shifts have changed. Emails can't be taken back.",
|
|
236
|
+
"week.send.yes": "Yes, send the changes",
|
|
237
|
+
"staff.link.question": "Email {name} a new link?",
|
|
238
|
+
"staff.link.consequence": "Their old link and calendar feed stop working straight away. We'll email {name} the new ones, and they'll need to add the new calendar feed.",
|
|
239
|
+
"staff.link.consequence_first": "We'll email {name} a link to their own page and calendar feed.",
|
|
240
|
+
"staff.link.yes": "Yes, email a new link",
|
|
241
|
+
"staff.link.no": "No, not now",
|
|
242
|
+
"staff.remove.question": "Take {name} off the roster?",
|
|
243
|
+
"staff.remove.consequence": "Their shifts from now on, their leave and their link go, and we'll email {name} to say so. Their past shifts stay for the hours export. This can't be undone.",
|
|
244
|
+
"staff.remove.yes": "Yes, take {name} off",
|
|
245
|
+
"staff.remove.no": "No, keep them on the roster",
|
|
246
|
+
"leave.remove.question": "Remove {name}'s leave, {from} to {to}?",
|
|
247
|
+
"leave.remove.consequence": "We'll email {name} to say these days away are off the roster, so they can be rostered on them. This can't be undone.",
|
|
248
|
+
"leave.remove.yes": "Yes, remove this leave",
|
|
249
|
+
"email.removed.subject": "You're no longer on {business}'s roster",
|
|
250
|
+
"email.removed.body": "{business} has taken you off its roster.",
|
|
251
|
+
"email.removed.next": "Any shifts and days away you had from now on are cancelled, and your own page and calendar feed no longer work. If this isn't right, please talk to {business}.",
|
|
252
|
+
"email.leave_removed.subject": "Your leave has been removed: {from} to {to}",
|
|
253
|
+
"email.leave_removed.body": "{business} has taken your days away from {from} to {to} off the roster, so you may be rostered on those days.",
|
|
254
|
+
"email.leave_removed.next": "If you're still going to be away, please talk to {business}.",
|
|
181
255
|
};
|
|
182
256
|
const tl = {
|
|
183
257
|
"week.title": "Iskedyul: linggo ng {date}",
|
|
@@ -223,7 +297,6 @@ const tl = {
|
|
|
223
297
|
"staff.link_sent": "May link na",
|
|
224
298
|
"staff.no_link": "Wala pang link",
|
|
225
299
|
"staff.remove": "Alisin sa iskedyul",
|
|
226
|
-
"staff.remove_confirm": "Oo, alisin sila. Aalisin ang mga shift nila mula ngayon.",
|
|
227
300
|
"leave.title": "Leave",
|
|
228
301
|
"leave.none": "Walang paparating na leave.",
|
|
229
302
|
"leave.from": "Unang araw na wala",
|
|
@@ -266,6 +339,44 @@ const tl = {
|
|
|
266
339
|
"csv.end": "Tapos",
|
|
267
340
|
"csv.break": "Pahinga (minuto)",
|
|
268
341
|
"csv.hours": "Oras",
|
|
342
|
+
"confirm.no": "Huwag, panatilihin",
|
|
343
|
+
"error.confirm_needed": "Pakikumpirma muna. Walang nagbago.",
|
|
344
|
+
"shift.remove.question": "Alisin ang shift ni {name} sa {when}?",
|
|
345
|
+
"shift.remove.consequence": "Nailathala na ang linggong ito, kaya ie-email namin si {name} na wala na ang shift na ito kapag tapos ka nang magbago. Hindi na ito maibabalik.",
|
|
346
|
+
"shift.remove.consequence_manual": "Nailathala na ang linggong ito, kaya ie-email si {name} na wala na ang shift na ito kapag ipinadala mo ang mga pagbabago. Hindi na ito maibabalik.",
|
|
347
|
+
"shift.remove.consequence_gone": "Wala na si {name} sa iskedyul, kaya walang ie-email. Hindi na ito maibabalik.",
|
|
348
|
+
"shift.remove.yes": "Oo, alisin ang shift na ito",
|
|
349
|
+
"week.publish.question": "Ilathala ang linggo ng {date}?",
|
|
350
|
+
"week.publish.consequence": "Ie-email namin sa {count} tao ang kanilang mga shift para sa linggo, may calendar file, at makikita ito ng mga tauhan sa sarili nilang page. Hindi na mababawi ang mga email.",
|
|
351
|
+
"week.publish.consequence_one": "Ie-email namin sa 1 tao ang kanyang mga shift para sa linggo, may calendar file, at makikita ito ng mga tauhan sa sarili nilang page. Hindi na mababawi ang email.",
|
|
352
|
+
"week.publish.consequence_none": "Walang ie-email. Kapag nailathala na, makikita ng mga tauhan ang linggo sa sarili nilang page.",
|
|
353
|
+
"week.publish.consequence_all": "Ie-email namin ang lahat ng may shift sa linggong iyon, may calendar file, at makikita ito ng mga tauhan sa sarili nilang page. Hindi na mababawi ang mga email.",
|
|
354
|
+
"week.publish.yes": "Oo, ilathala at i-email",
|
|
355
|
+
"week.publish.no": "Huwag muna",
|
|
356
|
+
"week.send.question": "Ipadala ang mga pagbabago sa linggo ng {date}?",
|
|
357
|
+
"week.send.consequence": "Ie-email namin ang {count} tao na nagbago ang mga shift. Hindi na mababawi ang mga email.",
|
|
358
|
+
"week.send.consequence_one": "Ie-email namin ang 1 tao na nagbago ang mga shift. Hindi na mababawi ang email.",
|
|
359
|
+
"week.send.consequence_none": "Walang nagbagong shift mula nang huling i-email sila, kaya walang ie-email.",
|
|
360
|
+
"week.send.consequence_all": "Ie-email namin ang lahat ng nagbago ang mga shift. Hindi na mababawi ang mga email.",
|
|
361
|
+
"week.send.yes": "Oo, ipadala ang mga pagbabago",
|
|
362
|
+
"staff.link.question": "I-email kay {name} ang bagong link?",
|
|
363
|
+
"staff.link.consequence": "Hihinto agad ang luma nilang link at calendar feed. Ie-email namin kay {name} ang mga bago, at kailangan nilang idagdag ang bagong calendar feed.",
|
|
364
|
+
"staff.link.consequence_first": "Ie-email namin kay {name} ang link sa sarili nilang page at calendar feed.",
|
|
365
|
+
"staff.link.yes": "Oo, i-email ang bagong link",
|
|
366
|
+
"staff.link.no": "Huwag muna",
|
|
367
|
+
"staff.remove.question": "Alisin si {name} sa iskedyul?",
|
|
368
|
+
"staff.remove.consequence": "Aalisin ang mga shift nila mula ngayon, ang kanilang leave at ang kanilang link, at ie-email namin si {name} tungkol dito. Mananatili ang mga nakaraang shift para sa export ng mga oras. Hindi na ito maibabalik.",
|
|
369
|
+
"staff.remove.yes": "Oo, alisin si {name}",
|
|
370
|
+
"staff.remove.no": "Huwag, panatilihin sila sa iskedyul",
|
|
371
|
+
"leave.remove.question": "Alisin ang leave ni {name}, {from} hanggang {to}?",
|
|
372
|
+
"leave.remove.consequence": "Ie-email namin si {name} na wala na sa iskedyul ang mga araw na ito na wala sila, kaya puwede na silang i-iskedyul sa mga iyon. Hindi na ito maibabalik.",
|
|
373
|
+
"leave.remove.yes": "Oo, alisin ang leave na ito",
|
|
374
|
+
"email.removed.subject": "Wala ka na sa iskedyul ng {business}",
|
|
375
|
+
"email.removed.body": "Inalis ka na ng {business} sa kanilang iskedyul.",
|
|
376
|
+
"email.removed.next": "Kinansela na ang mga shift at leave mo mula ngayon, at hindi na gagana ang sarili mong page at calendar feed. Kung mali ito, pakausap ang {business}.",
|
|
377
|
+
"email.leave_removed.subject": "Inalis ang iyong leave: {from} hanggang {to}",
|
|
378
|
+
"email.leave_removed.body": "Inalis ng {business} sa iskedyul ang mga araw na wala ka mula {from} hanggang {to}, kaya puwede kang ma-iskedyul sa mga araw na iyon.",
|
|
379
|
+
"email.leave_removed.next": "Kung wala ka pa rin sa mga araw na iyon, pakausap ang {business}.",
|
|
269
380
|
};
|
|
270
381
|
const taglish = {
|
|
271
382
|
"week.title": "Roster: week ng {date}",
|
|
@@ -311,7 +422,6 @@ const taglish = {
|
|
|
311
422
|
"staff.link_sent": "May link na",
|
|
312
423
|
"staff.no_link": "Wala pang link",
|
|
313
424
|
"staff.remove": "Tanggalin sa roster",
|
|
314
|
-
"staff.remove_confirm": "Oo, tanggalin sila. Matatanggal ang shifts nila from now on.",
|
|
315
425
|
"leave.title": "Leave",
|
|
316
426
|
"leave.none": "Walang upcoming na leave.",
|
|
317
427
|
"leave.from": "First day na wala",
|
|
@@ -354,5 +464,43 @@ const taglish = {
|
|
|
354
464
|
"csv.end": "End",
|
|
355
465
|
"csv.break": "Break (minutes)",
|
|
356
466
|
"csv.hours": "Hours",
|
|
467
|
+
"confirm.no": "Hindi, i-keep",
|
|
468
|
+
"error.confirm_needed": "Paki-confirm muna. Walang nagbago.",
|
|
469
|
+
"shift.remove.question": "Tanggalin ang shift ni {name} sa {when}?",
|
|
470
|
+
"shift.remove.consequence": "Published na ang week na 'to, kaya ie-email namin si {name} na wala na ang shift na 'to pag tapos ka nang mag-edit. Hindi na 'to maibabalik.",
|
|
471
|
+
"shift.remove.consequence_manual": "Published na ang week na 'to, kaya ie-email si {name} na wala na ang shift na 'to pag ni-send mo ang changes. Hindi na 'to maibabalik.",
|
|
472
|
+
"shift.remove.consequence_gone": "Wala na si {name} sa roster, kaya walang ie-email. Hindi na 'to maibabalik.",
|
|
473
|
+
"shift.remove.yes": "Oo, tanggalin ang shift",
|
|
474
|
+
"week.publish.question": "I-publish ang week ng {date}?",
|
|
475
|
+
"week.publish.consequence": "Ie-email namin sa {count} tao ang shifts nila for the week, may calendar file, at makikita ito ng staff sa sarili nilang page. Hindi na mababawi ang emails.",
|
|
476
|
+
"week.publish.consequence_one": "Ie-email namin sa 1 tao ang shifts niya for the week, may calendar file, at makikita ito ng staff sa sarili nilang page. Hindi na mababawi ang email.",
|
|
477
|
+
"week.publish.consequence_none": "Walang ie-email. Pag published na, makikita ng staff ang week sa sarili nilang page.",
|
|
478
|
+
"week.publish.consequence_all": "Ie-email namin lahat ng may shift sa week na 'yon, may calendar file, at makikita ito ng staff sa sarili nilang page. Hindi na mababawi ang emails.",
|
|
479
|
+
"week.publish.yes": "Oo, i-publish at i-email",
|
|
480
|
+
"week.publish.no": "'Wag muna",
|
|
481
|
+
"week.send.question": "I-send ang changes sa week ng {date}?",
|
|
482
|
+
"week.send.consequence": "Ie-email namin ang {count} tao na nagbago ang shifts. Hindi na mababawi ang emails.",
|
|
483
|
+
"week.send.consequence_one": "Ie-email namin ang 1 tao na nagbago ang shifts. Hindi na mababawi ang email.",
|
|
484
|
+
"week.send.consequence_none": "Walang nagbagong shifts since huling email, kaya walang ie-email.",
|
|
485
|
+
"week.send.consequence_all": "Ie-email namin lahat ng nagbago ang shifts. Hindi na mababawi ang emails.",
|
|
486
|
+
"week.send.yes": "Oo, i-send ang changes",
|
|
487
|
+
"staff.link.question": "I-email kay {name} ang bagong link?",
|
|
488
|
+
"staff.link.consequence": "Hihinto agad ang lumang link at calendar feed nila. Ie-email namin kay {name} ang mga bago, at kailangan nilang i-add ang bagong calendar feed.",
|
|
489
|
+
"staff.link.consequence_first": "Ie-email namin kay {name} ang link sa sarili nilang page at calendar feed.",
|
|
490
|
+
"staff.link.yes": "Oo, i-email ang bagong link",
|
|
491
|
+
"staff.link.no": "'Wag muna",
|
|
492
|
+
"staff.remove.question": "Tanggalin si {name} sa roster?",
|
|
493
|
+
"staff.remove.consequence": "Matatanggal ang shifts nila from now on, ang leave nila at ang link nila, at ie-email namin si {name} tungkol dito. Mananatili ang past shifts para sa hours export. Hindi na 'to maibabalik.",
|
|
494
|
+
"staff.remove.yes": "Oo, tanggalin si {name}",
|
|
495
|
+
"staff.remove.no": "Hindi, i-keep sila sa roster",
|
|
496
|
+
"leave.remove.question": "Tanggalin ang leave ni {name}, {from} to {to}?",
|
|
497
|
+
"leave.remove.consequence": "Ie-email namin si {name} na wala na sa roster ang days na wala sila, kaya puwede na silang i-roster sa mga 'yon. Hindi na 'to maibabalik.",
|
|
498
|
+
"leave.remove.yes": "Oo, tanggalin ang leave",
|
|
499
|
+
"email.removed.subject": "Wala ka na sa roster ng {business}",
|
|
500
|
+
"email.removed.body": "Tinanggal ka na ng {business} sa roster nila.",
|
|
501
|
+
"email.removed.next": "Cancelled na ang shifts at leave mo from now on, at hindi na gagana ang sarili mong page at calendar feed. Kung mali 'to, paki-kausap ang {business}.",
|
|
502
|
+
"email.leave_removed.subject": "Natanggal ang leave mo: {from} to {to}",
|
|
503
|
+
"email.leave_removed.body": "Tinanggal ng {business} sa roster ang days na wala ka from {from} to {to}, kaya puwede kang ma-roster sa mga araw na 'yon.",
|
|
504
|
+
"email.leave_removed.next": "Kung wala ka pa rin sa mga araw na 'yon, paki-kausap ang {business}.",
|
|
357
505
|
};
|
|
358
506
|
export const ROSTER_WORDS = { en, tl, taglish };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-roster",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A staff roster for Workbench apps: staff, shifts and leave in the app's own database. The owner builds a week and publishes it; each person is emailed their shifts with a calendar file and has their own page and calendar feed, and later changes are emailed to the people they touch. A gaps check finds times with too few people on, hoursFor() keeps bookings inside rostered shifts, and the hours export goes to the owner's own payroll. No pay rates and no AI.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|