@cellaware/utils 8.3.3 → 8.3.5

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.
@@ -115,7 +115,9 @@ export interface DatagridCondition {
115
115
  value2?: string;
116
116
  }
117
117
  export declare function initDatagridCondition(): DatagridCondition;
118
- export declare function summarizeCondition(condition: DatagridCondition, localeMessageFn: (language: string, messageId: string) => Promise<string>, markdown?: boolean): Promise<string>;
118
+ export declare function summarizeCondition(condition: DatagridCondition, localeMessageFn: (language: string, messageId: string) => Promise<string>): Promise<string>;
119
+ export declare function summarizeConditionMarkdown(condition: DatagridCondition, localeMessageFn: (language: string, messageId: string) => Promise<string>): Promise<string>;
120
+ export declare function summarizeConditionHtml(condition: DatagridCondition, localeMessageFn: (language: string, messageId: string) => Promise<string>): Promise<string>;
119
121
  export declare function codifyCondition(condition: DatagridCondition): string;
120
122
  /**
121
123
  * Equivalent of `parseNumeric` in front end
@@ -265,48 +265,68 @@ export function initDatagridCondition() {
265
265
  value: ''
266
266
  };
267
267
  }
268
- export async function summarizeCondition(condition, localeMessageFn, markdown) {
268
+ export async function summarizeCondition(condition, localeMessageFn) {
269
269
  let ruleStr = '';
270
- if (!!markdown) {
271
- switch (condition.rule) {
272
- case ConditionalFormatRule.BETWEEN:
273
- ruleStr = `**${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}** ${condition.value} **${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, 'conditional-format-rule-and')}** ${condition.value2}`;
274
- break;
275
- case ConditionalFormatRule.BLANK:
276
- case ConditionalFormatRule.NOT_BLANK:
277
- ruleStr = `**${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}**`;
278
- break;
279
- default:
280
- if (condition.dataType === 'text') {
281
- ruleStr = `**${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}** '${condition.value}'`;
282
- }
283
- else {
284
- ruleStr = `**${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}** ${condition.value}`;
285
- }
286
- break;
287
- }
288
- return `\`${condition.columnName}\` ${ruleStr}`;
270
+ switch (condition.rule) {
271
+ case ConditionalFormatRule.BETWEEN:
272
+ ruleStr = `${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)} ${condition.value} ${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, 'conditional-format-rule-and')} ${condition.value2}`;
273
+ break;
274
+ case ConditionalFormatRule.BLANK:
275
+ case ConditionalFormatRule.NOT_BLANK:
276
+ ruleStr = `${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}`;
277
+ break;
278
+ default:
279
+ if (condition.dataType === 'text') {
280
+ ruleStr = `${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)} '${condition.value}'`;
281
+ }
282
+ else {
283
+ ruleStr = `${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)} ${condition.value}`;
284
+ }
285
+ break;
289
286
  }
290
- else {
291
- switch (condition.rule) {
292
- case ConditionalFormatRule.BETWEEN:
293
- ruleStr = `${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)} ${condition.value} ${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, 'conditional-format-rule-and')} ${condition.value2}`;
294
- break;
295
- case ConditionalFormatRule.BLANK:
296
- case ConditionalFormatRule.NOT_BLANK:
297
- ruleStr = `${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}`;
298
- break;
299
- default:
300
- if (condition.dataType === 'text') {
301
- ruleStr = `${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)} '${condition.value}'`;
302
- }
303
- else {
304
- ruleStr = `${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)} ${condition.value}`;
305
- }
306
- break;
307
- }
308
- return `${condition.columnName} ${ruleStr}`;
287
+ return `${condition.columnName} ${ruleStr}`;
288
+ }
289
+ export async function summarizeConditionMarkdown(condition, localeMessageFn) {
290
+ let ruleStr = '';
291
+ switch (condition.rule) {
292
+ case ConditionalFormatRule.BETWEEN:
293
+ ruleStr = `**${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}** ${condition.value} **${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, 'conditional-format-rule-and')}** ${condition.value2}`;
294
+ break;
295
+ case ConditionalFormatRule.BLANK:
296
+ case ConditionalFormatRule.NOT_BLANK:
297
+ ruleStr = `**${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}**`;
298
+ break;
299
+ default:
300
+ if (condition.dataType === 'text') {
301
+ ruleStr = `**${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}** '${condition.value}'`;
302
+ }
303
+ else {
304
+ ruleStr = `**${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}** ${condition.value}`;
305
+ }
306
+ break;
309
307
  }
308
+ return `\`${condition.columnName}\` ${ruleStr}`;
309
+ }
310
+ export async function summarizeConditionHtml(condition, localeMessageFn) {
311
+ let ruleStr = '';
312
+ switch (condition.rule) {
313
+ case ConditionalFormatRule.BETWEEN:
314
+ ruleStr = `<b>${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}</b> ${condition.value} <b>${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, 'conditional-format-rule-and')}</b> ${condition.value2}`;
315
+ break;
316
+ case ConditionalFormatRule.BLANK:
317
+ case ConditionalFormatRule.NOT_BLANK:
318
+ ruleStr = `<b>${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}</b>`;
319
+ break;
320
+ default:
321
+ if (condition.dataType === 'text') {
322
+ ruleStr = `<b>${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}</b> '${condition.value}'`;
323
+ }
324
+ else {
325
+ ruleStr = `<b>${await localeMessageFn(CHATWMS_DEFAULT_LANGUAGE, condition.rule)}</b> ${condition.value}`;
326
+ }
327
+ break;
328
+ }
329
+ return `<code>${condition.columnName}</code> ${ruleStr}`;
310
330
  }
311
331
  export function codifyCondition(condition) {
312
332
  // NOTE: since we check for action/unsafe SQL with every query, we do not need to check for SQL injection here.
@@ -848,6 +868,11 @@ export function datagridToString(datagridState, rowCnt) {
848
868
  }
849
869
  const totalRowCnt = datagridState.adjRowData.length;
850
870
  rowCnt = rowCnt ?? totalRowCnt;
871
+ if (rowCnt < totalRowCnt) {
872
+ const message = `Displaying the first ${rowCnt} rows.`;
873
+ htmlBuf += `<p style="font-style: italic;">${message}</p>`;
874
+ markdownBuf += `\n*${message}*\n\n`;
875
+ }
851
876
  // Header:
852
877
  htmlBuf += '<table>\n\t<thead>\n\t\t<tr>';
853
878
  let columns = [];
@@ -928,11 +953,6 @@ export function datagridToString(datagridState, rowCnt) {
928
953
  rowIdx++;
929
954
  }
930
955
  htmlBuf += '\n\t</tbody>\n</table>';
931
- if (rowCnt < totalRowCnt) {
932
- const message = `Displaying the first ${rowCnt} rows.`;
933
- htmlBuf += `<blockquote>${message}</blockquote>`;
934
- markdownBuf += `\n> ${message}\n\n`;
935
- }
936
956
  return {
937
957
  html: htmlBuf,
938
958
  markdown: markdownBuf
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.3.3",
3
+ "version": "8.3.5",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",