@saltcorn/history-control 0.5.3 → 0.5.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/rowdiffview.js +19 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/history-control",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Allow users to interact with row history",
5
5
  "main": "index.js",
6
6
  "dependencies": {
package/rowdiffview.js CHANGED
@@ -20,6 +20,7 @@ const {
20
20
  select,
21
21
  option,
22
22
  h2,
23
+ time,
23
24
  button,
24
25
  } = require("@saltcorn/markup/tags");
25
26
  const { radio_group, checkbox_group } = require("@saltcorn/markup/helpers");
@@ -183,6 +184,7 @@ const run = async (
183
184
  hist,
184
185
  state
185
186
  );
187
+
186
188
  return div(
187
189
  {
188
190
  class: ["accordion"],
@@ -190,6 +192,21 @@ const run = async (
190
192
  },
191
193
  rendered.map((html, ix) => {
192
194
  const row = hist[ix];
195
+ let d = row._time;
196
+ const jsdate = d;
197
+ const locale = (req) => {
198
+ //console.log(req && req.getLocale ? req.getLocale() : undefined);
199
+ return req?.getLocale?.() || "en";
200
+ };
201
+ const loc = locale(extraArgs.req);
202
+ let format = date_format || "YYYY-MM-DD HH:mm";
203
+ let timeHtml = time(
204
+ {
205
+ datetime: new Date(d).toISOString(),
206
+ "locale-date-format": encodeURIComponent(JSON.stringify(format)),
207
+ },
208
+ moment(jsdate).locale(loc).format(format)
209
+ );
193
210
  return div(
194
211
  { class: "accordion-item" },
195
212
  h2(
@@ -203,10 +220,8 @@ const run = async (
203
220
  "aria-expanded": "false",
204
221
  "aria-controls": `a${stateHash}tab${ix}`,
205
222
  },
206
- date_format
207
- ? moment(row._time).format(date_format)
208
- : row._time.toString(),
209
- " - ",
223
+ timeHtml,
224
+ " - ",
210
225
  emails[row._userid]
211
226
  )
212
227
  ),