From b447f080bfdca2410f8eda3b24d7fa2c78a74372 Mon Sep 17 00:00:00 2001 From: Victor Tomaili Date: Thu, 11 Jul 2024 15:26:51 +0300 Subject: [PATCH] - Determine the default editor type as TimeSpanEditor for timespan fields. - Introduce TimeSpanEditor that works with TimeSpan Hours and Minutes only. - Implement fixes for string left fill for minutes and hours less than 10. --- packages/corelib/dist/index.d.ts | 18 ++-- packages/corelib/src/ui/editors/timeeditor.ts | 84 ++++++++++++++----- packages/corelib/wwwroot/index.global.d.ts | 17 +++- .../BasicPropertyProcessor.Editing.cs | 4 +- 4 files changed, 94 insertions(+), 29 deletions(-) diff --git a/packages/corelib/dist/index.d.ts b/packages/corelib/dist/index.d.ts index 0cb09365f7..3419abaaba 100644 --- a/packages/corelib/dist/index.d.ts +++ b/packages/corelib/dist/index.d.ts @@ -3894,17 +3894,25 @@ interface TimeEditorOptions { endHour?: any; intervalMinutes?: any; } -declare class TimeEditor

extends EditorWidget

{ +declare class TimeEditorBase

extends EditorWidget

{ static createDefaultElement(): HTMLElement; readonly domNode: HTMLSelectElement; - private minutes; + protected minutes: Fluent; constructor(props: EditorProps

); + get_readOnly(): boolean; + set_readOnly(value: boolean): void; +} +declare class TimeEditor

extends TimeEditorBase

{ get value(): number; protected get_value(): number; set value(value: number); protected set_value(value: number): void; - get_readOnly(): boolean; - set_readOnly(value: boolean): void; +} +declare class TimeSpanEditor

extends TimeEditorBase

{ + protected get_value(): string; + protected set_value(value: string): void; + get value(): string; + set value(value: string); } interface EmailEditorOptions { @@ -5614,4 +5622,4 @@ declare class EntityDialog extends BaseDialog

implements IEdit type Constructor = new (...args: any[]) => T; -export { AggregateFormatting, Aggregators, type AnyIconClass, ArgumentNullException, Authorization, AutoNumeric, type AutoNumericOptions, BaseDialog, BaseEditorFiltering, BaseFiltering, BasePanel, BooleanEditor, BooleanFiltering, BooleanFormatter, type CKEditorConfig, type CancellableViewCallback, CaptureOperationType, CascadedWidgetLink, CategoryAttribute, CheckLookupEditor, type CheckLookupEditorOptions, CheckTreeEditor, type CheckTreeItem, CheckboxFormatter, type ClassTypeInfo, CloseButtonAttribute, ColumnPickerDialog, ColumnSelection, ColumnsBase, ColumnsKeyAttribute, Combobox, type ComboboxCommonOptions, ComboboxEditor, type ComboboxEditorOptions, type ComboboxFilterOptions, type ComboboxFormatResult, type ComboboxInplaceAddOptions, type ComboboxItem, type ComboboxOptions, type ComboboxSearchQuery, type ComboboxSearchResult, type ComboboxType, Config, type ConfirmDialogOptions, type Constructor, type CreateWidgetParams, Criteria, CriteriaBuilder, CriteriaOperator, type CriteriaWithText, CssClassAttribute, Culture, type DataChangeInfo, DataGrid, DateEditor, type DateEditorOptions, DateFiltering, type DateFormat, DateFormatter, DateTimeEditor, type DateTimeEditorOptions, DateTimeFiltering, DateTimeFormatter, DateYearEditor, type DateYearEditorOptions, type DebouncedFunction, DecimalEditor, type DecimalEditorOptions, DecimalFiltering, Decorators, DefaultValueAttribute, type DeleteRequest, type DeleteResponse, Dialog, type DialogButton, DialogExtensions, type DialogOptions, type DialogProviderType, DialogTexts, type DialogType, DialogTypeAttribute, DialogTypeRegistry, type Dictionary, DisplayNameAttribute, type EditorAddon, EditorAttribute, EditorFiltering, EditorOptionAttribute, type EditorProps, type EditorType, EditorTypeAttribute, EditorTypeAttributeBase, type EditorTypeInfo, EditorTypeRegistry, EditorUtils, EditorWidget, ElementAttribute, EmailAddressEditor, EmailEditor, type EmailEditorOptions, EntityDialog, EntityGrid, EntityTypeAttribute, Enum, EnumEditor, type EnumEditorOptions, EnumFiltering, EnumFormatter, EnumKeyAttribute, EnumTypeRegistry, ErrorHandling, Exception, FileDownloadFormatter, type FileUploadConstraints, FileUploadEditor, type FileUploadEditorOptions, FilterDialog, FilterDisplayBar, type FilterFieldSelectOptions, type FilterLine, type FilterOperator, FilterOperators, FilterPanel, FilterStore, FilterWidgetBase, FilterableAttribute, FilteringTypeRegistry, FlexifyAttribute, Fluent, FormKeyAttribute, type Format, type Formatter, type FormatterType, type FormatterTypeInfo, FormatterTypeRegistry, GeneratedCodeAttribute, GridPageInit, type GridPersistanceFlags, GridRadioSelectionMixin, type GridRadioSelectionMixinOptions, GridRowSelectionMixin, type GridRowSelectionMixinOptions, GridSelectAllButtonHelper, GridUtils, type GroupByElement, type GroupByResult, type GroupInfo, type Grouping, type HandleRouteEvent, HiddenAttribute, HintAttribute, HtmlContentEditor, type HtmlContentEditorOptions, HtmlNoteContentEditor, HtmlReportContentEditor, IBooleanValue, type IDataGrid, IDialog, IDoubleValue, IEditDialog, IFiltering, type IFrameDialogOptions, IGetEditValue, IInitializeColumn, IQuickFiltering, IReadOnly, type IRowDefinition, ISetEditValue, ISlickFormatter, IStringValue, IValidateRequired, type IconClassName, type IdPrefixType, IdPropertyAttribute, ImageUploadEditor, type ImageUploadEditorOptions, InsertableAttribute, IntegerEditor, type IntegerEditorOptions, IntegerFiltering, type InterfaceTypeInfo, InvalidCastException, Invariant, IsActivePropertyAttribute, ItemNameAttribute, type KnownIconClass, LT, LayoutTimer, LazyLoadHelper, type ListRequest, type ListResponse, LocalTextPrefixAttribute, type Locale, Lookup, LookupEditor, LookupEditorBase, type LookupEditorOptions, LookupFiltering, type LookupOptions, MaskedEditor, type MaskedEditorOptions, MaxLengthAttribute, MaximizableAttribute, MemberType, type MessageDialogOptions, MinuteFormatter, MultipleFileUploadEditor, type MultipleFileUploadEditorOptions, MultipleImageUploadEditor, NamePropertyAttribute, type NoInfer, type NotifyMap, type NumberFormat, NumberFormatter, OneWayAttribute, OptionAttribute, OptionsTypeAttribute, type PagerOptions, type PagingInfo, type PagingOptions, PanelAttribute, PanelPageInit, PasswordEditor, type PersistedGridColumn, type PersistedGridSettings, PlaceholderAttribute, type PostToServiceOptions, type PostToUrlOptions, PrefixedContext, PropertyCategories, PropertyCategory, PropertyCategoryTitle, PropertyDialog, PropertyField, PropertyFieldCaption, PropertyFieldEditor, type PropertyFieldElement, PropertyFieldLineBreak, PropertyGrid, PropertyGridMode, type PropertyGridOptions, type PropertyItem, PropertyItemSlickConverter, type PropertyItemsData, PropertyPanel, PropertyTabItem, PropertyTabList, PropertyTabPane, PropertyTabPanes, PropertyTabs, type QuickFilter, type QuickFilterArgs, QuickFilterBar, type QuickFilterBarOptions, type QuickSearchField, QuickSearchInput, type QuickSearchInputOptions, RadioButtonEditor, type RadioButtonEditorOptions, ReadOnlyAttribute, Recaptcha, type RecaptchaOptions, ReflectionOptionsSetter, ReflectionUtils, RemoteView, type RemoteViewAjaxCallback, type RemoteViewFilter, type RemoteViewOptions, type RemoteViewProcessCallback, type RequestErrorInfo, RequiredAttribute, ResizableAttribute, ResponsiveAttribute, RetrieveColumnSelection, type RetrieveLocalizationRequest, type RetrieveLocalizationResponse, type RetrieveRequest, type RetrieveResponse, Router, type SaveRequest, type SaveRequestWithAttachment, type SaveResponse, type SaveWithLocalizationRequest, ScriptData, Select2, type Select2AjaxOptions, type Select2Element, type Select2FormatResult, type Select2Item, type Select2Options, type Select2QueryOptions, type Select2Result, SelectEditor, type SelectEditorOptions, ServiceAttribute, type ServiceError, ServiceLookupEditor, ServiceLookupEditorBase, type ServiceLookupEditorOptions, ServiceLookupFiltering, type ServiceOptions, type ServiceRequest, type ServiceResponse, type SettingStorage, SlickFormatting, SlickHelper, SlickPager, SlickTreeHelper, StaticPanelAttribute, StringEditor, StringFiltering, type StringLiteral, SubDialogHelper, type SummaryOptions, SummaryType, TabsExtensions, TemplatedDialog, TemplatedPanel, TemplatedWidget, TextAreaEditor, type TextAreaEditorOptions, type TextColor, TimeEditor, type TimeEditorOptions, type ToastContainerOptions, Toastr, type ToastrOptions, type ToolButton, type ToolButtonProps, Toolbar, ToolbarButton, type ToolbarOptions, Tooltip, type TooltipOptions, TreeGridMixin, type TreeGridMixinOptions, type Type, type TypeInfo, type TypeMember, URLEditor, type UndeleteRequest, type UndeleteResponse, UpdatableAttribute, UploadHelper, type UploadInputOptions, type UploadResponse, type UploadedFile, Uploader, type UploaderBatch, type UploaderErrorData, type UploaderOptions, type UploaderRequest, type UploaderSuccessData, UrlFormatter, type UserDefinition, type UtilityColor, type ValidatableElement, type ValidateEventDelegate, type ValidationErrorItem, type ValidationErrorList, type ValidationErrorMap, ValidationHelper, type ValidationProvider, type ValidationRules, type ValidationRulesMap, type ValidationValue, Validator, type ValidatorOptions, Widget, type WidgetProps, addClass, addCustomAttribute, addEmptyOption, addLocalText, addOption, addTypeMember, addValidationRule, alert, alertDialog, any, appendToNode, associateWidget, attrEncode, bgColor, blockUI, blockUndo, canLoadScriptData, cancelDialogButton, cast, centerDialog, classTypeInfo, clearKeys, clearOptions, coalesce, compareStringFactory, confirm, confirmDialog, count, dbText, dbTryText, deassociateWidget, debounce, deepClone, defaultNotifyOptions, delegateCombine, delegateContains, delegateRemove, editorTypeInfo, endsWith, executeEverytimeWhenVisible, executeOnceWhenVisible, extend, faIcon, type faIconKey, fabIcon, type fabIconKey, fetchScriptData, fieldsProxy, findElementWithRelativeId, first, format, formatDate, formatDayHourAndMin, formatISODateTimeUTC, formatNumber, formatterTypeInfo, getActiveRequests, getBaseType, getColumns, getColumnsAsync, getColumnsData, getColumnsDataAsync, getColumnsScript, getCookie, getCustomAttribute, getCustomAttributes, getForm, getFormAsync, getFormData, getFormDataAsync, getFormScript, getGlobalObject, getInstanceType, getLookup, getLookupAsync, getMembers, getNested, getRemoteData, getRemoteDataAsync, getScriptData, getScriptDataHash, getType, getTypeFullName, getTypeNameProp, getTypeRegistry, getTypeShortName, getTypes, getWidgetFrom, getWidgetName, getjQuery, gridPageInit, groupBy, handleScriptDataError, hasBSModal, hasCustomAttribute, hasUIDialog, htmlEncode, iconClassName, iframeDialog, indexOf, information, informationDialog, initFormType, initFullHeightGridPage, initializeTypes, insert, interfaceTypeInfo, isArray, isArrayLike, isAssignableFrom, isBS3, isBS5Plus, isEmptyOrNull, isEnum, isInstanceOfType, isMobileView, isPromiseLike, isSameOrigin, isTrimmedEmpty, isValue, jQueryPatch, keyOf, layoutFillHeight, layoutFillHeightValue, localText, localeFormat, newBodyDiv, noDialogButton, notifyError, notifyInfo, notifySuccess, notifyWarning, okDialogButton, omitUndefined, outerHtml, padLeft, panelPageInit, parseCriteria, parseDate, parseDayHourAndMin, parseDecimal, parseHourAndMin, parseISODateTime, parseInteger, parseQueryString, peekScriptData, positionToastContainer, postToService, postToUrl, prefixedText, proxyTexts, reactPatch, registerClass, registerEditor, registerEnum, registerFormatter, registerInterface, registerType, reloadLookup, reloadLookupAsync, removeClass, removeValidationRule, replaceAll, requestFinished, requestStarting, resolveServiceUrl, resolveUrl, round, safeCast, serviceCall, serviceRequest, setEquality, setRegisteredScripts, setScriptData, setTypeNameProp, single, splitDateString, startsWith, stringFormat, stringFormatLocale, stripDiacritics, success, successDialog, text, textColor, toGrouping, toId, toSingleLine, today, toggleClass, triggerLayoutOnShow, trim, trimEnd, trimStart, trimToEmpty, trimToNull, trunc, tryFirst, tryGetText, tryGetWidget, turkishLocaleCompare, turkishLocaleToLower, turkishLocaleToUpper, typeInfoProperty, uiAndBSButtonNoConflict, useIdPrefix, validateOptions, validatorAbortHandler, warning, warningDialog, yesDialogButton, zeroPad }; +export { AggregateFormatting, Aggregators, type AnyIconClass, ArgumentNullException, Authorization, AutoNumeric, type AutoNumericOptions, BaseDialog, BaseEditorFiltering, BaseFiltering, BasePanel, BooleanEditor, BooleanFiltering, BooleanFormatter, type CKEditorConfig, type CancellableViewCallback, CaptureOperationType, CascadedWidgetLink, CategoryAttribute, CheckLookupEditor, type CheckLookupEditorOptions, CheckTreeEditor, type CheckTreeItem, CheckboxFormatter, type ClassTypeInfo, CloseButtonAttribute, ColumnPickerDialog, ColumnSelection, ColumnsBase, ColumnsKeyAttribute, Combobox, type ComboboxCommonOptions, ComboboxEditor, type ComboboxEditorOptions, type ComboboxFilterOptions, type ComboboxFormatResult, type ComboboxInplaceAddOptions, type ComboboxItem, type ComboboxOptions, type ComboboxSearchQuery, type ComboboxSearchResult, type ComboboxType, Config, type ConfirmDialogOptions, type Constructor, type CreateWidgetParams, Criteria, CriteriaBuilder, CriteriaOperator, type CriteriaWithText, CssClassAttribute, Culture, type DataChangeInfo, DataGrid, DateEditor, type DateEditorOptions, DateFiltering, type DateFormat, DateFormatter, DateTimeEditor, type DateTimeEditorOptions, DateTimeFiltering, DateTimeFormatter, DateYearEditor, type DateYearEditorOptions, type DebouncedFunction, DecimalEditor, type DecimalEditorOptions, DecimalFiltering, Decorators, DefaultValueAttribute, type DeleteRequest, type DeleteResponse, Dialog, type DialogButton, DialogExtensions, type DialogOptions, type DialogProviderType, DialogTexts, type DialogType, DialogTypeAttribute, DialogTypeRegistry, type Dictionary, DisplayNameAttribute, type EditorAddon, EditorAttribute, EditorFiltering, EditorOptionAttribute, type EditorProps, type EditorType, EditorTypeAttribute, EditorTypeAttributeBase, type EditorTypeInfo, EditorTypeRegistry, EditorUtils, EditorWidget, ElementAttribute, EmailAddressEditor, EmailEditor, type EmailEditorOptions, EntityDialog, EntityGrid, EntityTypeAttribute, Enum, EnumEditor, type EnumEditorOptions, EnumFiltering, EnumFormatter, EnumKeyAttribute, EnumTypeRegistry, ErrorHandling, Exception, FileDownloadFormatter, type FileUploadConstraints, FileUploadEditor, type FileUploadEditorOptions, FilterDialog, FilterDisplayBar, type FilterFieldSelectOptions, type FilterLine, type FilterOperator, FilterOperators, FilterPanel, FilterStore, FilterWidgetBase, FilterableAttribute, FilteringTypeRegistry, FlexifyAttribute, Fluent, FormKeyAttribute, type Format, type Formatter, type FormatterType, type FormatterTypeInfo, FormatterTypeRegistry, GeneratedCodeAttribute, GridPageInit, type GridPersistanceFlags, GridRadioSelectionMixin, type GridRadioSelectionMixinOptions, GridRowSelectionMixin, type GridRowSelectionMixinOptions, GridSelectAllButtonHelper, GridUtils, type GroupByElement, type GroupByResult, type GroupInfo, type Grouping, type HandleRouteEvent, HiddenAttribute, HintAttribute, HtmlContentEditor, type HtmlContentEditorOptions, HtmlNoteContentEditor, HtmlReportContentEditor, IBooleanValue, type IDataGrid, IDialog, IDoubleValue, IEditDialog, IFiltering, type IFrameDialogOptions, IGetEditValue, IInitializeColumn, IQuickFiltering, IReadOnly, type IRowDefinition, ISetEditValue, ISlickFormatter, IStringValue, IValidateRequired, type IconClassName, type IdPrefixType, IdPropertyAttribute, ImageUploadEditor, type ImageUploadEditorOptions, InsertableAttribute, IntegerEditor, type IntegerEditorOptions, IntegerFiltering, type InterfaceTypeInfo, InvalidCastException, Invariant, IsActivePropertyAttribute, ItemNameAttribute, type KnownIconClass, LT, LayoutTimer, LazyLoadHelper, type ListRequest, type ListResponse, LocalTextPrefixAttribute, type Locale, Lookup, LookupEditor, LookupEditorBase, type LookupEditorOptions, LookupFiltering, type LookupOptions, MaskedEditor, type MaskedEditorOptions, MaxLengthAttribute, MaximizableAttribute, MemberType, type MessageDialogOptions, MinuteFormatter, MultipleFileUploadEditor, type MultipleFileUploadEditorOptions, MultipleImageUploadEditor, NamePropertyAttribute, type NoInfer, type NotifyMap, type NumberFormat, NumberFormatter, OneWayAttribute, OptionAttribute, OptionsTypeAttribute, type PagerOptions, type PagingInfo, type PagingOptions, PanelAttribute, PanelPageInit, PasswordEditor, type PersistedGridColumn, type PersistedGridSettings, PlaceholderAttribute, type PostToServiceOptions, type PostToUrlOptions, PrefixedContext, PropertyCategories, PropertyCategory, PropertyCategoryTitle, PropertyDialog, PropertyField, PropertyFieldCaption, PropertyFieldEditor, type PropertyFieldElement, PropertyFieldLineBreak, PropertyGrid, PropertyGridMode, type PropertyGridOptions, type PropertyItem, PropertyItemSlickConverter, type PropertyItemsData, PropertyPanel, PropertyTabItem, PropertyTabList, PropertyTabPane, PropertyTabPanes, PropertyTabs, type QuickFilter, type QuickFilterArgs, QuickFilterBar, type QuickFilterBarOptions, type QuickSearchField, QuickSearchInput, type QuickSearchInputOptions, RadioButtonEditor, type RadioButtonEditorOptions, ReadOnlyAttribute, Recaptcha, type RecaptchaOptions, ReflectionOptionsSetter, ReflectionUtils, RemoteView, type RemoteViewAjaxCallback, type RemoteViewFilter, type RemoteViewOptions, type RemoteViewProcessCallback, type RequestErrorInfo, RequiredAttribute, ResizableAttribute, ResponsiveAttribute, RetrieveColumnSelection, type RetrieveLocalizationRequest, type RetrieveLocalizationResponse, type RetrieveRequest, type RetrieveResponse, Router, type SaveRequest, type SaveRequestWithAttachment, type SaveResponse, type SaveWithLocalizationRequest, ScriptData, Select2, type Select2AjaxOptions, type Select2Element, type Select2FormatResult, type Select2Item, type Select2Options, type Select2QueryOptions, type Select2Result, SelectEditor, type SelectEditorOptions, ServiceAttribute, type ServiceError, ServiceLookupEditor, ServiceLookupEditorBase, type ServiceLookupEditorOptions, ServiceLookupFiltering, type ServiceOptions, type ServiceRequest, type ServiceResponse, type SettingStorage, SlickFormatting, SlickHelper, SlickPager, SlickTreeHelper, StaticPanelAttribute, StringEditor, StringFiltering, type StringLiteral, SubDialogHelper, type SummaryOptions, SummaryType, TabsExtensions, TemplatedDialog, TemplatedPanel, TemplatedWidget, TextAreaEditor, type TextAreaEditorOptions, type TextColor, TimeEditor, TimeEditorBase, type TimeEditorOptions, TimeSpanEditor, type ToastContainerOptions, Toastr, type ToastrOptions, type ToolButton, type ToolButtonProps, Toolbar, ToolbarButton, type ToolbarOptions, Tooltip, type TooltipOptions, TreeGridMixin, type TreeGridMixinOptions, type Type, type TypeInfo, type TypeMember, URLEditor, type UndeleteRequest, type UndeleteResponse, UpdatableAttribute, UploadHelper, type UploadInputOptions, type UploadResponse, type UploadedFile, Uploader, type UploaderBatch, type UploaderErrorData, type UploaderOptions, type UploaderRequest, type UploaderSuccessData, UrlFormatter, type UserDefinition, type UtilityColor, type ValidatableElement, type ValidateEventDelegate, type ValidationErrorItem, type ValidationErrorList, type ValidationErrorMap, ValidationHelper, type ValidationProvider, type ValidationRules, type ValidationRulesMap, type ValidationValue, Validator, type ValidatorOptions, Widget, type WidgetProps, addClass, addCustomAttribute, addEmptyOption, addLocalText, addOption, addTypeMember, addValidationRule, alert, alertDialog, any, appendToNode, associateWidget, attrEncode, bgColor, blockUI, blockUndo, canLoadScriptData, cancelDialogButton, cast, centerDialog, classTypeInfo, clearKeys, clearOptions, coalesce, compareStringFactory, confirm, confirmDialog, count, dbText, dbTryText, deassociateWidget, debounce, deepClone, defaultNotifyOptions, delegateCombine, delegateContains, delegateRemove, editorTypeInfo, endsWith, executeEverytimeWhenVisible, executeOnceWhenVisible, extend, faIcon, type faIconKey, fabIcon, type fabIconKey, fetchScriptData, fieldsProxy, findElementWithRelativeId, first, format, formatDate, formatDayHourAndMin, formatISODateTimeUTC, formatNumber, formatterTypeInfo, getActiveRequests, getBaseType, getColumns, getColumnsAsync, getColumnsData, getColumnsDataAsync, getColumnsScript, getCookie, getCustomAttribute, getCustomAttributes, getForm, getFormAsync, getFormData, getFormDataAsync, getFormScript, getGlobalObject, getInstanceType, getLookup, getLookupAsync, getMembers, getNested, getRemoteData, getRemoteDataAsync, getScriptData, getScriptDataHash, getType, getTypeFullName, getTypeNameProp, getTypeRegistry, getTypeShortName, getTypes, getWidgetFrom, getWidgetName, getjQuery, gridPageInit, groupBy, handleScriptDataError, hasBSModal, hasCustomAttribute, hasUIDialog, htmlEncode, iconClassName, iframeDialog, indexOf, information, informationDialog, initFormType, initFullHeightGridPage, initializeTypes, insert, interfaceTypeInfo, isArray, isArrayLike, isAssignableFrom, isBS3, isBS5Plus, isEmptyOrNull, isEnum, isInstanceOfType, isMobileView, isPromiseLike, isSameOrigin, isTrimmedEmpty, isValue, jQueryPatch, keyOf, layoutFillHeight, layoutFillHeightValue, localText, localeFormat, newBodyDiv, noDialogButton, notifyError, notifyInfo, notifySuccess, notifyWarning, okDialogButton, omitUndefined, outerHtml, padLeft, panelPageInit, parseCriteria, parseDate, parseDayHourAndMin, parseDecimal, parseHourAndMin, parseISODateTime, parseInteger, parseQueryString, peekScriptData, positionToastContainer, postToService, postToUrl, prefixedText, proxyTexts, reactPatch, registerClass, registerEditor, registerEnum, registerFormatter, registerInterface, registerType, reloadLookup, reloadLookupAsync, removeClass, removeValidationRule, replaceAll, requestFinished, requestStarting, resolveServiceUrl, resolveUrl, round, safeCast, serviceCall, serviceRequest, setEquality, setRegisteredScripts, setScriptData, setTypeNameProp, single, splitDateString, startsWith, stringFormat, stringFormatLocale, stripDiacritics, success, successDialog, text, textColor, toGrouping, toId, toSingleLine, today, toggleClass, triggerLayoutOnShow, trim, trimEnd, trimStart, trimToEmpty, trimToNull, trunc, tryFirst, tryGetText, tryGetWidget, turkishLocaleCompare, turkishLocaleToLower, turkishLocaleToUpper, typeInfoProperty, uiAndBSButtonNoConflict, useIdPrefix, validateOptions, validatorAbortHandler, warning, warningDialog, yesDialogButton, zeroPad }; diff --git a/packages/corelib/src/ui/editors/timeeditor.ts b/packages/corelib/src/ui/editors/timeeditor.ts index 67878650ef..18072deaa6 100644 --- a/packages/corelib/src/ui/editors/timeeditor.ts +++ b/packages/corelib/src/ui/editors/timeeditor.ts @@ -1,5 +1,5 @@ -import { Fluent, toId } from "../../base"; -import { IDoubleValue, IReadOnly } from "../../interfaces"; +import { Fluent, toId } from "../../base"; +import { IDoubleValue, IReadOnly, IStringValue } from "../../interfaces"; import { addOption } from "../../q"; import { Decorators } from "../../types/decorators"; import { EditorProps, EditorWidget } from "./editorwidget"; @@ -12,13 +12,12 @@ export interface TimeEditorOptions { intervalMinutes?: any; } -@Decorators.registerEditor('Serenity.TimeEditor', [IDoubleValue, IReadOnly]) -export class TimeEditor

extends EditorWidget

{ +export class TimeEditorBase

extends EditorWidget

{ static override createDefaultElement(): HTMLElement { return document.createElement("select"); } declare readonly domNode: HTMLSelectElement; - private minutes: Fluent; + protected minutes: Fluent; constructor(props: EditorProps

) { super(props); @@ -31,17 +30,39 @@ export class TimeEditor

extends } for (var h = (this.options.startHour || 0); h <= (this.options.endHour || 23); h++) { - addOption(input, h.toString(), ((h < 10) ? ('0' + h) : h.toString())); + var hour = ((h < 10) ? (`0${h}`) : h.toString()); + addOption(input, hour, hour); } this.minutes = Fluent("select").class('editor s-TimeEditor minute').insertAfter(input); this.minutes.on("change", () => Fluent.trigger(this.domNode, "change")); for (var m = 0; m <= 59; m += (this.options.intervalMinutes || 5)) { - addOption(this.minutes, m.toString(), ((m < 10) ? ('0' + m) : m.toString())); + var minute = ((m < 10) ? (`0${m}`) : m.toString()); + addOption(this.minutes, minute, minute); + } + } + + get_readOnly(): boolean { + return this.domNode.classList.contains('readonly'); + } + + set_readOnly(value: boolean): void { + + if (value !== this.get_readOnly()) { + if (value) { + this.element.addClass('readonly').attr('readonly', 'readonly'); + } + else { + this.element.removeClass('readonly').removeAttr('readonly'); + } + EditorUtils.setReadonly(this.minutes, value); } } +} +@Decorators.registerEditor('Serenity.TimeEditor', [IDoubleValue, IReadOnly]) +export class TimeEditor

extends TimeEditorBase

{ public get value(): number { var hour = toId(this.domNode.value); var minute = toId(this.minutes.val()); @@ -59,15 +80,20 @@ export class TimeEditor

extends if (!value) { if (this.options.noEmptyOption) { this.domNode.value = this.options.startHour; - this.minutes.val('0'); + this.minutes.val('00'); } else { this.domNode.value = ''; - this.minutes.val('0'); + this.minutes.val('00'); } } else { - this.domNode.value = Math.floor(value / 60).toString(); + var hour = Math.floor(value / 60); + if (hour < 10) + this.domNode.value = `0${hour}`; + else + this.domNode.value = hour.toString(); + this.minutes.val("" + (value % 60)); } } @@ -75,21 +101,41 @@ export class TimeEditor

extends protected set_value(value: number): void { this.value = value; } +} - get_readOnly(): boolean { - return this.domNode.classList.contains('readonly'); - } +@Decorators.registerEditor('Serenity.TimeSpanEditor', [IStringValue, IReadOnly]) +export class TimeSpanEditor

extends TimeEditorBase

{ - set_readOnly(value: boolean): void { + protected get_value(): string { + return this.value; + } - if (value !== this.get_readOnly()) { - if (value) { - this.element.addClass('readonly').attr('readonly', 'readonly'); + protected set_value(value: string): void { + this.value = value; + } + public get value(): string { + var hour = toId(this.domNode.value); + var minute = toId(this.minutes.val()); + if (hour == null || minute == null) { + return null; + } + return `${hour}:${minute}:00.00`; + } + public set value(value: string) { + if (!value) { + if (this.options.noEmptyOption) { + this.domNode.value = this.options.startHour; + this.minutes.val('0'); } else { - this.element.removeClass('readonly').removeAttr('readonly'); + this.domNode.value = ''; + this.minutes.val('0'); } - EditorUtils.setReadonly(this.minutes, value); + } + else { + var parts = value.split(':'); + this.domNode.value = parts[0]; + this.minutes.val(parts[1]); } } } \ No newline at end of file diff --git a/packages/corelib/wwwroot/index.global.d.ts b/packages/corelib/wwwroot/index.global.d.ts index 528af6d24e..1ff307a943 100644 --- a/packages/corelib/wwwroot/index.global.d.ts +++ b/packages/corelib/wwwroot/index.global.d.ts @@ -676,6 +676,7 @@ declare namespace Slick { private _columnCssRulesR; private _currentEditor; private _data; + private _draggableInstance; private _editController; private _emptyNode; private _headerColumnWidthDiff; @@ -5183,17 +5184,25 @@ declare namespace Serenity { endHour?: any; intervalMinutes?: any; } - class TimeEditor

extends EditorWidget

{ + class TimeEditorBase

extends EditorWidget

{ static createDefaultElement(): HTMLElement; readonly domNode: HTMLSelectElement; - private minutes; + protected minutes: Fluent; constructor(props: EditorProps

); + get_readOnly(): boolean; + set_readOnly(value: boolean): void; + } + class TimeEditor

extends TimeEditorBase

{ get value(): number; protected get_value(): number; set value(value: number); protected set_value(value: number): void; - get_readOnly(): boolean; - set_readOnly(value: boolean): void; + } + class TimeSpanEditor

extends TimeEditorBase

{ + protected get_value(): string; + protected set_value(value: string): void; + get value(): string; + set value(value: string); } interface EmailEditorOptions { diff --git a/src/Serenity.Net.Entity/PropertyGrid/BasicPropertyProcessor/BasicPropertyProcessor.Editing.cs b/src/Serenity.Net.Entity/PropertyGrid/BasicPropertyProcessor/BasicPropertyProcessor.Editing.cs index a40b19c8db..2b8c42ae63 100644 --- a/src/Serenity.Net.Entity/PropertyGrid/BasicPropertyProcessor/BasicPropertyProcessor.Editing.cs +++ b/src/Serenity.Net.Entity/PropertyGrid/BasicPropertyProcessor/BasicPropertyProcessor.Editing.cs @@ -1,4 +1,4 @@ -namespace Serenity.PropertyGrid; +namespace Serenity.PropertyGrid; public partial class BasicPropertyProcessor : PropertyProcessor { @@ -214,6 +214,8 @@ private static string AutoDetermineEditorType(Type valueType, Type enumType, IDi } else if (valueType == typeof(DateTime)) return "Date"; + else if (valueType == typeof(TimeSpan)) + return "TimeSpan"; else if (valueType == typeof(bool)) return "Boolean"; else if (valueType == typeof(decimal) || valueType == typeof(double) || valueType == typeof(float))