From 31246a11a0528dcf78f54162f0d1fd181f7cde0c Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 24 Mar 2026 00:49:55 +0500 Subject: [PATCH] Add date difference calculation functionality (#10673) * Add date difference calculation functionality Signed-off-by: Denis Bykhov * Fix Signed-off-by: Denis Bykhov * Fix formatting Signed-off-by: Denis Bykhov --------- Signed-off-by: Denis Bykhov --- models/process/src/functions.ts | 14 +++ models/server-process/src/index.ts | 4 + plugins/process-assets/lang/cs.json | 3 +- plugins/process-assets/lang/de.json | 3 +- plugins/process-assets/lang/en.json | 3 +- plugins/process-assets/lang/es.json | 3 +- plugins/process-assets/lang/fr.json | 3 +- plugins/process-assets/lang/it.json | 3 +- plugins/process-assets/lang/ja.json | 3 +- plugins/process-assets/lang/pt-br.json | 3 +- plugins/process-assets/lang/pt.json | 3 +- plugins/process-assets/lang/ru.json | 7 +- plugins/process-assets/lang/tr.json | 3 +- plugins/process-assets/lang/zh.json | 3 +- .../ContextSelectorPopup.svelte | 88 ++++++++++---- .../DateDifferenceEditor.svelte | 107 ++++++++++++++++++ plugins/process-resources/src/plugin.ts | 6 +- plugins/process-resources/src/utils.ts | 2 +- plugins/process/src/index.ts | 1 + .../src/components/list/ListCategories.svelte | 2 +- server-plugins/process-resources/src/index.ts | 6 +- .../process-resources/src/transform.ts | 29 ++++- server-plugins/process/src/index.ts | 3 +- 23 files changed, 258 insertions(+), 44 deletions(-) create mode 100644 plugins/process-resources/src/components/transformEditors/DateDifferenceEditor.svelte diff --git a/models/process/src/functions.ts b/models/process/src/functions.ts index a3c6def254..62f49afee9 100644 --- a/models/process/src/functions.ts +++ b/models/process/src/functions.ts @@ -610,6 +610,20 @@ export function defineFunctions (builder: Builder): void { process.function.DateFromNumber ) + builder.createDoc( + process.class.ProcessFunction, + core.space.Model, + { + of: core.class.TypeDate, + to: core.class.TypeNumber, + category: 'attribute', + label: process.string.DateDifference, + type: 'convert', + editor: process.transformEditor.DateDifferenceEditor + }, + process.function.DateDifference + ) + builder.createDoc( process.class.ProcessFunction, core.space.Model, diff --git a/models/server-process/src/index.ts b/models/server-process/src/index.ts index 56daf790e1..ad39002e89 100644 --- a/models/server-process/src/index.ts +++ b/models/server-process/src/index.ts @@ -211,6 +211,10 @@ export function createModel (builder: Builder): void { func: serverProcess.transform.DayFromDate }) + builder.mixin(process.function.DateDifference, process.class.ProcessFunction, serverProcess.mixin.FuncImpl, { + func: serverProcess.transform.DateDifference + }) + builder.mixin(process.function.Random, process.class.ProcessFunction, serverProcess.mixin.FuncImpl, { func: serverProcess.transform.Random }) diff --git a/plugins/process-assets/lang/cs.json b/plugins/process-assets/lang/cs.json index d1c1c89853..8f39f477f5 100644 --- a/plugins/process-assets/lang/cs.json +++ b/plugins/process-assets/lang/cs.json @@ -162,7 +162,8 @@ "DateFromText": "Datum ze stringu", "YearFromDate": "Rok z data", "MonthFromDate": "Měsíc z data", - "DayFromDate": "Den z data" + "DayFromDate": "Den z data", + "DateDifference": "Rozdíl dat" }, "error": { "MethodNotFound": "Metoda nenalezena: {methodId}", diff --git a/plugins/process-assets/lang/de.json b/plugins/process-assets/lang/de.json index 44c1c6809f..7fef53bfdb 100644 --- a/plugins/process-assets/lang/de.json +++ b/plugins/process-assets/lang/de.json @@ -162,7 +162,8 @@ "DateFromText": "Datum aus Text", "YearFromDate": "Jahr aus Datum", "MonthFromDate": "Monat aus Datum", - "DayFromDate": "Tag aus Datum" + "DayFromDate": "Tag aus Datum", + "DateDifference": "Datumsdifferenz" }, "error": { "MethodNotFound": "Methode nicht gefunden: {methodId}", diff --git a/plugins/process-assets/lang/en.json b/plugins/process-assets/lang/en.json index a310314daf..63961b48f2 100644 --- a/plugins/process-assets/lang/en.json +++ b/plugins/process-assets/lang/en.json @@ -167,7 +167,8 @@ "DateFromText": "Date from text", "YearFromDate": "Year from date", "MonthFromDate": "Month from date", - "DayFromDate": "Day from date" + "DayFromDate": "Day from date", + "DateDifference": "Date difference" }, "error": { "MethodNotFound": "Method not found: {methodId}", diff --git a/plugins/process-assets/lang/es.json b/plugins/process-assets/lang/es.json index f85aa11589..5c0b3b47bc 100644 --- a/plugins/process-assets/lang/es.json +++ b/plugins/process-assets/lang/es.json @@ -167,7 +167,8 @@ "DateFromText": "Fecha desde texto", "YearFromDate": "Año desde fecha", "MonthFromDate": "Mes desde fecha", - "DayFromDate": "Día desde fecha" + "DayFromDate": "Día desde fecha", + "DateDifference": "Diferencia de fechas" }, "error": { "MethodNotFound": "Método no encontrado: {methodId}", diff --git a/plugins/process-assets/lang/fr.json b/plugins/process-assets/lang/fr.json index ab333ee6be..de441fc6cc 100644 --- a/plugins/process-assets/lang/fr.json +++ b/plugins/process-assets/lang/fr.json @@ -167,7 +167,8 @@ "DateFromText": "Date depuis texte", "YearFromDate": "Année depuis date", "MonthFromDate": "Mois depuis date", - "DayFromDate": "Jour depuis date" + "DayFromDate": "Jour depuis date", + "DateDifference": "Différence de dates" }, "error": { "MethodNotFound": "Méthode introuvable : {methodId}", diff --git a/plugins/process-assets/lang/it.json b/plugins/process-assets/lang/it.json index 1618790ed0..edfa5e14ca 100644 --- a/plugins/process-assets/lang/it.json +++ b/plugins/process-assets/lang/it.json @@ -167,7 +167,8 @@ "DateFromText": "Data da testo", "YearFromDate": "Anno da data", "MonthFromDate": "Mese da data", - "DayFromDate": "Giorno da data" + "DayFromDate": "Giorno da data", + "DateDifference": "Differenza di date" }, "error": { "MethodNotFound": "Metodo non trovato: {methodId}", diff --git a/plugins/process-assets/lang/ja.json b/plugins/process-assets/lang/ja.json index fcf7c29ac6..34fa8c7487 100644 --- a/plugins/process-assets/lang/ja.json +++ b/plugins/process-assets/lang/ja.json @@ -166,7 +166,8 @@ "DateFromText": "テキストから日付", "YearFromDate": "日付から年", "MonthFromDate": "日付から月", - "DayFromDate": "日付から日" + "DayFromDate": "日付から日", + "DateDifference": "日付の差" }, "error": { "MethodNotFound": "メソッドが見つかりません: {methodId}", diff --git a/plugins/process-assets/lang/pt-br.json b/plugins/process-assets/lang/pt-br.json index 9439b5c930..c3d676f3dd 100644 --- a/plugins/process-assets/lang/pt-br.json +++ b/plugins/process-assets/lang/pt-br.json @@ -155,7 +155,8 @@ "DateFromText": "Data de texto", "YearFromDate": "Ano de data", "MonthFromDate": "Mês de data", - "DayFromDate": "Dia de data" + "DayFromDate": "Dia de data", + "DateDifference": "Diferença de datas" }, "error": { "MethodNotFound": "Método não encontrado: {methodId}", diff --git a/plugins/process-assets/lang/pt.json b/plugins/process-assets/lang/pt.json index d0e6af3cad..e6abcac702 100644 --- a/plugins/process-assets/lang/pt.json +++ b/plugins/process-assets/lang/pt.json @@ -167,7 +167,8 @@ "DateFromText": "Data de texto", "YearFromDate": "Ano de data", "MonthFromDate": "Mês de data", - "DayFromDate": "Dia de data" + "DayFromDate": "Dia de data", + "DateDifference": "Diferença de datas" }, "error": { "MethodNotFound": "Método não encontrado: {methodId}", diff --git a/plugins/process-assets/lang/ru.json b/plugins/process-assets/lang/ru.json index c6c1a4390e..a3432c1c6e 100644 --- a/plugins/process-assets/lang/ru.json +++ b/plugins/process-assets/lang/ru.json @@ -163,11 +163,12 @@ "TextFromCheckbox": "Строка из чекбокса", "NumberFromDate": "Число из даты", "DateFromNumber": "Дата из числа", - "NumberFromString": "Число из строки", - "DateFromString": "Дата из строки", + "NumberFromText": "Число из текста", + "DateFromText": "Дата из текста", "YearFromDate": "Год из даты", "MonthFromDate": "Месяц из даты", - "DayFromDate": "День из даты" + "DayFromDate": "День из даты", + "DateDifference": "Разница дат" }, "error": { "MethodNotFound": "Метод не найден: {methodId}", diff --git a/plugins/process-assets/lang/tr.json b/plugins/process-assets/lang/tr.json index a9154070c7..5cae8eb743 100644 --- a/plugins/process-assets/lang/tr.json +++ b/plugins/process-assets/lang/tr.json @@ -162,7 +162,8 @@ "DateFromText": "Metinden tarih", "YearFromDate": "Tarihten yıl", "MonthFromDate": "Tarihten ay", - "DayFromDate": "Tarihten gün" + "DayFromDate": "Tarihten gün", + "DateDifference": "Tarih farkı" }, "error": { "MethodNotFound": "Metod bulunamadı: {methodId}", diff --git a/plugins/process-assets/lang/zh.json b/plugins/process-assets/lang/zh.json index e911b8a14b..cff0efcaa5 100644 --- a/plugins/process-assets/lang/zh.json +++ b/plugins/process-assets/lang/zh.json @@ -167,7 +167,8 @@ "DateFromText": "文本到日期", "YearFromDate": "日期到年份", "MonthFromDate": "日期到月份", - "DayFromDate": "日期到天" + "DayFromDate": "日期到天", + "DateDifference": "日期差异" }, "error": { "MethodNotFound": "找不到方法:{methodId}", diff --git a/plugins/process-resources/src/components/attributeEditors/ContextSelectorPopup.svelte b/plugins/process-resources/src/components/attributeEditors/ContextSelectorPopup.svelte index a1d920cf1e..59a81d1075 100644 --- a/plugins/process-resources/src/components/attributeEditors/ContextSelectorPopup.svelte +++ b/plugins/process-resources/src/components/attributeEditors/ContextSelectorPopup.svelte @@ -165,8 +165,12 @@