Skip to content

Commit

Permalink
Merge pull request #187 from KorzhCom/dev
Browse files Browse the repository at this point in the history
Version 1.5.3
  • Loading branch information
korzh authored Mar 2, 2024
2 parents f63bc43 + 0fe0265 commit 9c1969c
Show file tree
Hide file tree
Showing 18 changed files with 335 additions and 218 deletions.
3 changes: 2 additions & 1 deletion easydata.js/packs/core/__tests__/assign-deep.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from 'vitest'
import {utils} from "../src/public_api"

// Create a fake DOM for testing with $.ajax
test('AssignDeep', () => {
let object1 = {
data: {
Expand Down Expand Up @@ -30,4 +31,4 @@ test('AssignDeep', () => {
expect(result.val).toBe(object1.val);
expect(result.prop).toBe(object2.prop);
expect(result.column).toBe(object3.column);
})
})
37 changes: 37 additions & 0 deletions easydata.js/packs/core/__tests__/assign-deep2.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { expect, test } from 'vitest'
import {utils} from "../src/public_api"

test('should deeply assign properties from source to target', () => {
const source = {
scalar: 'value',
refObject: {
nested: 'nestedValue',
array: [1, 2, 3],
html: document.createElement('div'),
},
refArray: [{nested: 'nestedValue'}, 1, 'two'],
refArrayRef: [{nested: 'nestedValueRef'}, 1, 'two'],
htmlRef: document.createElement('div'),
};

// @ts-ignore
source.refArray[3] = source.refArray;

const target = utils.assignDeep({}, source);

expect(target).toEqual({
scalar: 'value',
refObject: {
nested: 'nestedValue',
array: [1, 2, 3],
html: document.createElement('div'),
},
refArray: [{nested: 'nestedValue'}, 1, 'two', target.refArray],
refArrayRef: [{nested: 'nestedValueRef'}, 1, 'two'],
htmlRef: document.createElement('div'),
});
expect(target.refObject).not.toBe(source.refObject);
expect(target.refObject.html).toBe(source.refObject.html);
expect(target.refArray[0]).toBe(source.refArray[0]);
expect(target.refArray[3]).toBe(source.refArray);
});
2 changes: 1 addition & 1 deletion easydata.js/packs/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"files": [
"dist"
]
}
}
25 changes: 25 additions & 0 deletions easydata.js/packs/core/src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ export namespace i18n {
else if (format == 'F') {
format = buildLongDateTimeFormat(DataType.DateTime);
}
else if (format == 'u') {
format = buildUniversalDateTimeFormat(dataType);
}
else {
format = buildUniversalDateTimeFormat(dataType);
}
}
else {
format = buildShortDateTimeFormat(dataType);
Expand Down Expand Up @@ -471,6 +477,25 @@ export namespace i18n {
return format;
}

function buildUniversalDateTimeFormat(dataType: DataType): string {
const localeSettings = getLocaleSettings();
let format: string;
const dateFormat = 'yyyy-MM-dd';
switch (dataType) {
case DataType.Date:
format = dateFormat;
break;
case DataType.Time:
format = localeSettings.shortTimeFormat;
break;
default:
format = dateFormat + ' ' + localeSettings.shortTimeFormat;
break;
}

return format;
}

/**
* Converts a numeric value to the string taking into the account the decimal separator
* @param num - the number to convert
Expand Down
Loading

0 comments on commit 9c1969c

Please sign in to comment.