@idevs/corelib 0.0.96 → 1.0.0

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 (117) hide show
  1. package/CHANGELOG.md +737 -0
  2. package/README.md +221 -24
  3. package/dist/editors/checkboxButtonEditor.d.ts +3 -1
  4. package/dist/editors/checkboxButtonEditor.d.ts.map +1 -0
  5. package/dist/editors/checkboxButtonEditor.js +28 -18
  6. package/dist/editors/checkboxButtonEditor.js.map +1 -1
  7. package/dist/editors/dateMonthEditor.d.ts +3 -1
  8. package/dist/editors/dateMonthEditor.d.ts.map +1 -0
  9. package/dist/editors/dateMonthEditor.js +14 -7
  10. package/dist/editors/dateMonthEditor.js.map +1 -1
  11. package/dist/editors/index.d.ts +2 -1
  12. package/dist/editors/index.d.ts.map +1 -0
  13. package/dist/editors/index.js +18 -2
  14. package/dist/editors/index.js.map +1 -1
  15. package/dist/formatters/formatters.d.ts +2 -1
  16. package/dist/formatters/formatters.d.ts.map +1 -0
  17. package/dist/formatters/formatters.js +39 -25
  18. package/dist/formatters/formatters.js.map +1 -1
  19. package/dist/formatters/index.d.ts +2 -1
  20. package/dist/formatters/index.d.ts.map +1 -0
  21. package/dist/formatters/index.js +17 -1
  22. package/dist/formatters/index.js.map +1 -1
  23. package/dist/globals/index.d.ts +16 -9
  24. package/dist/globals/index.d.ts.map +1 -0
  25. package/dist/globals/index.js +65 -105
  26. package/dist/globals/index.js.map +1 -1
  27. package/dist/helpers/custom-fonts.d.ts +4 -0
  28. package/dist/helpers/custom-fonts.d.ts.map +1 -0
  29. package/dist/helpers/custom-fonts.js +14 -0
  30. package/dist/helpers/custom-fonts.js.map +1 -0
  31. package/dist/helpers/dialogHelper.d.ts +6 -9
  32. package/dist/helpers/dialogHelper.d.ts.map +1 -0
  33. package/dist/helpers/dialogHelper.js +17 -10
  34. package/dist/helpers/dialogHelper.js.map +1 -1
  35. package/dist/helpers/excelExportHelper.d.ts +2 -1
  36. package/dist/helpers/excelExportHelper.d.ts.map +1 -0
  37. package/dist/helpers/excelExportHelper.js +7 -4
  38. package/dist/helpers/excelExportHelper.js.map +1 -1
  39. package/dist/helpers/gridHelper.d.ts +2 -1
  40. package/dist/helpers/gridHelper.d.ts.map +1 -0
  41. package/dist/helpers/gridHelper.js +14 -9
  42. package/dist/helpers/gridHelper.js.map +1 -1
  43. package/dist/helpers/index.d.ts +2 -1
  44. package/dist/helpers/index.d.ts.map +1 -0
  45. package/dist/helpers/index.js +20 -4
  46. package/dist/helpers/index.js.map +1 -1
  47. package/dist/helpers/pdfExportHelper.d.ts +10 -1
  48. package/dist/helpers/pdfExportHelper.d.ts.map +1 -0
  49. package/dist/helpers/pdfExportHelper.js +169 -7
  50. package/dist/helpers/pdfExportHelper.js.map +1 -1
  51. package/dist/index.d.ts +5 -2
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +26 -5
  54. package/dist/index.js.map +1 -1
  55. package/dist/types/common.d.ts +12 -0
  56. package/dist/types/common.d.ts.map +1 -0
  57. package/dist/types/common.js +3 -0
  58. package/dist/types/common.js.map +1 -0
  59. package/dist/types/export.d.ts +50 -0
  60. package/dist/types/export.d.ts.map +1 -0
  61. package/dist/types/export.js +24 -0
  62. package/dist/types/export.js.map +1 -0
  63. package/dist/types/index.d.ts +3 -0
  64. package/dist/types/index.d.ts.map +1 -0
  65. package/dist/types/index.js +19 -0
  66. package/dist/types/index.js.map +1 -0
  67. package/dist/ui/DropdownToolButton.d.ts +2 -1
  68. package/dist/ui/DropdownToolButton.d.ts.map +1 -0
  69. package/dist/ui/DropdownToolButton.js +15 -11
  70. package/dist/ui/DropdownToolButton.js.map +1 -1
  71. package/dist/ui/ToggleToolButton.d.ts +2 -1
  72. package/dist/ui/ToggleToolButton.d.ts.map +1 -0
  73. package/dist/ui/ToggleToolButton.js +7 -3
  74. package/dist/ui/ToggleToolButton.js.map +1 -1
  75. package/dist/ui/index.d.ts +2 -1
  76. package/dist/ui/index.d.ts.map +1 -0
  77. package/dist/ui/index.js +18 -2
  78. package/dist/ui/index.js.map +1 -1
  79. package/dist/utils/date.d.ts +16 -0
  80. package/dist/utils/date.d.ts.map +1 -0
  81. package/dist/utils/date.js +85 -0
  82. package/dist/utils/date.js.map +1 -0
  83. package/dist/utils/dom.d.ts +13 -0
  84. package/dist/utils/dom.d.ts.map +1 -0
  85. package/dist/utils/dom.js +78 -0
  86. package/dist/utils/dom.js.map +1 -0
  87. package/dist/utils/format.d.ts +22 -0
  88. package/dist/utils/format.d.ts.map +1 -0
  89. package/dist/utils/format.js +100 -0
  90. package/dist/utils/format.js.map +1 -0
  91. package/dist/utils/index.d.ts +4 -0
  92. package/dist/utils/index.d.ts.map +1 -0
  93. package/dist/utils/index.js +20 -0
  94. package/dist/utils/index.js.map +1 -0
  95. package/package.json +49 -26
  96. package/dist/ui/ToolDropdownButton.d.ts +0 -49
  97. package/dist/ui/ToolDropdownButton.js +0 -230
  98. package/dist/ui/ToolDropdownButton.js.map +0 -1
  99. package/src/editors/checkboxButtonEditor.ts +0 -184
  100. package/src/editors/dateMonthEditor.ts +0 -47
  101. package/src/editors/index.ts +0 -2
  102. package/src/formatters/formatters.ts +0 -181
  103. package/src/formatters/index.ts +0 -1
  104. package/src/globals/index.ts +0 -385
  105. package/src/helpers/dialogHelper.ts +0 -143
  106. package/src/helpers/excelExportHelper.ts +0 -29
  107. package/src/helpers/gridHelper.ts +0 -107
  108. package/src/helpers/html2pdf.d.ts +0 -19
  109. package/src/helpers/index.ts +0 -4
  110. package/src/helpers/pdfExportHelper.ts +0 -63
  111. package/src/index.ts +0 -5
  112. package/src/tsconfig.json +0 -29
  113. package/src/ui/DropdownToolButton.ts +0 -305
  114. package/src/ui/ToggleToolButton.ts +0 -71
  115. package/src/ui/index.ts +0 -2
  116. /package/{css → dist/css}/idevs.dropdown.css +0 -0
  117. /package/{css → dist/css}/idevs.print.css +0 -0
@@ -1,385 +0,0 @@
1
- import { DataGrid, ListRequest, ServiceResponse, ToolButton } from '@serenity-is/corelib'
2
- import { isEmptyOrNull } from '@serenity-is/corelib'
3
-
4
- declare global {
5
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
6
- interface Number {
7
- toDecimal(precision?: number): string
8
- toTimeString(): string
9
- }
10
-
11
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
12
- interface String {
13
- truncate(maxLength?: number): string
14
- toNumber(): number
15
- toMethodRound(method?: number): number
16
- }
17
-
18
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
19
- interface Date {
20
- toSqlDate(): string
21
- toNumber(): number
22
- }
23
-
24
- type IModalOptions = {
25
- events?: IEvent[]
26
- }
27
-
28
- type IEvent = {
29
- event: string
30
- callback: (e: Event) => Promise<unknown>
31
- }
32
- }
33
-
34
- Date.prototype.toSqlDate = function (): string {
35
- const date = this.valueOf()
36
- return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toISOString()
37
- }
38
-
39
- Date.prototype.toNumber = function (): number {
40
- const date = this.valueOf()
41
- const hours = date.getHours()
42
- const minutes = date.getMinutes()
43
- const seconds = date.getSeconds()
44
- return hours * 60 + minutes + seconds / 60
45
- }
46
-
47
- Number.prototype.toTimeString = function (): string {
48
- const value = this.valueOf()
49
- const hours = `0${Math.floor(value / 60)}`.slice(-2)
50
- const minutes = `0${value % 60}`.slice(-2)
51
- return `${hours}:${minutes}`
52
- }
53
-
54
- Number.prototype.toDecimal = function (precision?: number): string {
55
- const numb = precision || 0
56
- const options = {
57
- minimumFractionDigits: numb,
58
- maximumFractionDigits: numb,
59
- }
60
- let value = Intl.NumberFormat('en-US', options).format(this.valueOf())
61
- value = parseFloat(value.replace(/,/g, '')).toString()
62
- return Intl.NumberFormat('en-US', options).format(parseFloat(value))
63
- }
64
-
65
- String.prototype.truncate = function (maxLength: number) {
66
- const str = String(this)
67
- return str.length > maxLength ? str.substring(0, maxLength - 1) + '&hellip;' : str
68
- }
69
-
70
- String.prototype.toNumber = function () {
71
- return this.valueOf() ? parseFloat(this.valueOf().replace(/,/g, '')) : 0
72
- }
73
-
74
- String.prototype.toMethodRound = function (method: number): number {
75
- const input = parseFloat(this.valueOf())
76
- let value = isNaN(input) ? 0 : input
77
- if (value == 0) return 0
78
-
79
- const r = parseFloat(value.toFixed(2))
80
- switch (method) {
81
- case 1:
82
- value = r - (parseFloat(((r % 1) * 100).toFixed(2)) % 25) / 100
83
- break
84
-
85
- case 2:
86
- value = r - (parseFloat(((r % 1) * 100).toFixed(2)) % 50) / 100
87
- break
88
-
89
- case 3:
90
- value = Math.floor(r)
91
- break
92
-
93
- case 4:
94
- value = Math.floor(r) + (Math.floor((r % 1) * 100) + (25 - (Math.floor((r % 1) * 100) % 25))) / 100
95
- break
96
-
97
- case 5:
98
- value = Math.floor(r) + (Math.floor((r % 1) * 100) + (50 - (Math.floor((r % 1) * 100) % 50))) / 100
99
- break
100
-
101
- case 6:
102
- value = Math.ceil(r)
103
- break
104
-
105
- case 7:
106
- value = Math.floor(r) + (parseFloat((parseFloat(((r % 1) * 100).toString()) / 25).toFixed(0)) * 25) / 100
107
- break
108
-
109
- case 8:
110
- value = Math.floor(r) + (parseFloat((parseFloat(((r % 1) * 100).toString()) / 50).toFixed(0)) * 50) / 100
111
- break
112
-
113
- case 9:
114
- value = parseFloat(r.toFixed(0))
115
- break
116
-
117
- default:
118
- value = r
119
- break
120
- }
121
-
122
- return value
123
- }
124
-
125
- export function ToTimeString(value: number): string {
126
- const hours = `0${Math.floor(value / 60)}`.slice(-2)
127
- const minutes = `0${value % 60}`.slice(-2)
128
- return `${hours}:${minutes}`
129
- }
130
-
131
- export function ToNumber(date: Date): number {
132
- const hours = date.getHours()
133
- const minutes = date.getMinutes()
134
- const seconds = date.getSeconds()
135
- return hours * 60 + minutes * 60 + seconds
136
- }
137
-
138
- export function GetElementWidth(element?: HTMLElement): number {
139
- if (element) {
140
- return element.clientWidth
141
- }
142
-
143
- return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
144
- }
145
-
146
- export function GetElementHeight(element?: HTMLElement): number {
147
- if (element) {
148
- return element.clientHeight
149
- }
150
-
151
- return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
152
- }
153
-
154
- export function RemoveChildren(parent?: HTMLElement): void {
155
- if (!parent) {
156
- return
157
- }
158
-
159
- while (parent.firstChild) {
160
- parent.removeChild(parent.firstChild)
161
- }
162
- }
163
-
164
- export function IsOverflow(el: HTMLElement): boolean {
165
- return el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth
166
- }
167
-
168
- export function IsOverflowY(el: HTMLElement): boolean {
169
- return el.scrollHeight > el.clientHeight
170
- }
171
-
172
- export function IsOverflowX(el: HTMLElement): boolean {
173
- return el.scrollWidth > el.clientWidth
174
- }
175
-
176
- export function InnerDimensions(el: HTMLElement | null): [number, number] {
177
- if (!el) {
178
- return [0, 0]
179
- }
180
-
181
- const style = getComputedStyle(el)
182
- let width = el.clientWidth
183
- let height = el.clientHeight
184
-
185
- height -= parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)
186
- width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight)
187
-
188
- return [height, width]
189
- }
190
-
191
- export function neededTarget(el: HTMLElement, target: string): HTMLElement {
192
- if (target.slice(0, 1) == '.') {
193
- if (el.classList.contains(target.slice(1)) === false) {
194
- el = el.closest(target) as HTMLElement
195
- }
196
- } else {
197
- if (el.tagName.toLowerCase() !== target.toLowerCase()) {
198
- el = el.closest(target) as HTMLElement
199
- }
200
- }
201
- return el
202
- }
203
-
204
- export function dateStringOption(): Intl.DateTimeFormatOptions {
205
- return {
206
- year: 'numeric',
207
- month: '2-digit',
208
- day: '2-digit',
209
- }
210
- }
211
-
212
- export function toDateString(date: Date): string {
213
- return date.toLocaleString('en-GB', dateStringOption())
214
- }
215
-
216
- // export function GetModal(name: string, options?: IModalOptions): Modal {
217
- // const el = document.querySelector(name) as HTMLElement
218
- // if (options?.events?.length) {
219
- // options.events.forEach(callback => {
220
- // el.addEventListener(
221
- // callback.event,
222
- // (e: Event) => {
223
- // callback.callback(e)
224
- // },
225
- // { once: true },
226
- // )
227
- // })
228
- // }
229
-
230
- // return Modal.getOrCreateInstance(el, { backdrop: 'static' })
231
- // }
232
-
233
- export const setCookie = (name: string, value: string, expires?: number): void => {
234
- let cookie = `${name}=${value}`
235
- if (expires) {
236
- const date = new Date()
237
- date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000)
238
- const exp = `expires=${date.toUTCString()}`
239
- cookie = `${cookie}; ${exp}`
240
- }
241
- document.cookie = `${cookie}; path=/`
242
- }
243
-
244
- export type dateProxyInputOption = {
245
- name: string
246
- readOnly?: boolean
247
- width?: number
248
- }
249
-
250
- export function addDateProxyInput(opt: dateProxyInputOption): HTMLInputElement {
251
- const input: HTMLInputElement = document.querySelector(`input[name="${opt.name}"]`)
252
- const cloneInput: HTMLInputElement = input.cloneNode(true) as HTMLInputElement
253
- cloneInput.setAttribute('name', `${opt.name}-2`)
254
- cloneInput.setAttribute('id', `${input.getAttribute('id')}-2`)
255
- cloneInput.setAttribute('readonly', 'readonly')
256
- cloneInput.classList.remove('customValidate')
257
- cloneInput.classList.remove('s-DateEditor')
258
- cloneInput.classList.remove('s-Serenity-DateEditor')
259
- cloneInput.classList.remove('dateQ')
260
- cloneInput.classList.remove('hasDatepicker')
261
- if (opt.readOnly) {
262
- cloneInput.style.backgroundColor = 'rgba(var(--s-bright-rgb), 0.02)'
263
- } else {
264
- cloneInput.style.backgroundColor = 'white'
265
- }
266
- if (opt.width) {
267
- cloneInput.style.width = `${opt.width}px`
268
- }
269
-
270
- input.parentNode.insertBefore(cloneInput, input.nextSibling)
271
- input.classList.add('d-none')
272
-
273
- return cloneInput
274
- }
275
-
276
- export function updateDateProxyValue(name: string, dateValue: string | Date | null, locale?: string): void {
277
- let target = document.querySelector(`#${name}-2`) as HTMLInputElement
278
- if (!target) {
279
- target = document.querySelector(`input[name=${name}-2]`) as HTMLInputElement
280
- }
281
- if (isEmptyOrNull(dateValue?.toString())) {
282
- target.value = ''
283
- } else {
284
- if (!locale) {
285
- locale = 'en-GB'
286
- }
287
- target.value = (dateValue.constructor == Date ? dateValue : new Date(dateValue)).toLocaleString(
288
- locale,
289
- dateStringOption(),
290
- )
291
- }
292
- }
293
-
294
- export function toSqlDateString(date: Date): string {
295
- const offset = date.getTimezoneOffset()
296
- date = new Date(date.getTime() - offset * 60 * 1000)
297
- return date.toISOString().split('T')[0]
298
- }
299
-
300
- export enum PageSizes {
301
- A4 = 0,
302
- A3 = 1,
303
- }
304
-
305
- export enum PageOrientations {
306
- Portrait = 0,
307
- Landscape = 1,
308
- }
309
-
310
- export type PageSize = {
311
- Size: PageSize
312
- Orientation: PageOrientations
313
- }
314
-
315
- export type PageMargin = {
316
- MarginLeft: string
317
- MarginTop: string
318
- MarginRight: string
319
- MarginBottom: string
320
- }
321
-
322
- export type IdevsExportRequest = ListRequest & {
323
- viewName?: string
324
- companyName?: string
325
- reportName?: string
326
- selectionRange?: string
327
- conditionRange?: string
328
- logo?: string
329
- pageSize?: PageSize
330
- margin?: PageMargin
331
- entity?: unknown
332
- }
333
-
334
- export type IdevsExportOptions = IdevsExportRequest & {
335
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
336
- grid: DataGrid<any, any>
337
- service: string
338
- }
339
-
340
- export type ExportOptions = IdevsExportOptions & {
341
- title?: string
342
- hint?: string
343
- separator?: boolean
344
- exportType: 'PDF' | 'XLSX'
345
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
346
- onClick?: (e: any) => void
347
- }
348
-
349
- export type IdevsContentResponse = ServiceResponse & {
350
- Content: string
351
- }
352
-
353
- export function createExportToolButton(options: ExportOptions): ToolButton {
354
- return {
355
- hint: options.hint || options.exportType,
356
- title: options.title || '',
357
- cssClass: `export-${options.exportType.toLowerCase()}-button`,
358
- onClick: options.onClick,
359
- separator: options.separator,
360
- }
361
- }
362
-
363
- export function toBeginMonth(date: string): string {
364
- if (isEmptyOrNull(date)) {
365
- return date
366
- }
367
-
368
- return `${date.substring(0, 8)}01`
369
- }
370
-
371
- export function toEndMonth(date: string): string {
372
- if (isEmptyOrNull(date)) {
373
- return date
374
- }
375
-
376
- const dateArr = date.split('-')
377
- const d = new Date(parseInt(dateArr[0]), parseInt(dateArr[1]), 0)
378
-
379
- return `${date.substring(0, 8)}${d.getDate()}`
380
- }
381
-
382
- export class globals {
383
- // eslint-disable-next-line @typescript-eslint/no-empty-function
384
- public static load() {}
385
- }
@@ -1,143 +0,0 @@
1
- import { StringEditor, ToolButton } from '@serenity-is/corelib'
2
-
3
- /**
4
- * Use this function within updateInterface()
5
- * @param targets
6
- * @constructor
7
- */
8
- export function RemoveSelect2ClearButton(...targets: string[]): void {
9
- for (let i = 0; i < targets.length; i++) {
10
- $(`.${targets[i]} .select2-search-choice-close`)?.remove()
11
- }
12
- }
13
-
14
- export function EmailValidator(value: string): string | null {
15
- // eslint-disable-next-line no-useless-escape
16
- const filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
17
- return filter.test(value) ? null : 'Invalid email address'
18
- }
19
-
20
- export function NumberOnly(e: Event): boolean {
21
- const ev = e as KeyboardEvent
22
- if ('0123456789'.includes(ev.key)) {
23
- return true
24
- }
25
-
26
- e.preventDefault()
27
- return false
28
- }
29
-
30
- /**
31
- * Use GetDialogHelper function within function initToolbar()
32
- * @param helper
33
- * @constructor
34
- */
35
- export function GetDialogHelper(helper: DialogHelper): DialogHelper {
36
- if (helper) {
37
- return helper
38
- }
39
-
40
- return new DialogHelper()
41
- }
42
-
43
- export class DialogHelper {
44
- /**
45
- * Use this function within function getToolbarButtons()
46
- * @param buttons
47
- */
48
- public getToolbarButtons(buttons: ToolButton[]): ToolButton[] {
49
- const applyButton = buttons.find(b => b.cssClass === 'apply-changes-button')
50
- if (applyButton) {
51
- applyButton.visible = false
52
- }
53
-
54
- return buttons
55
- }
56
-
57
- /**
58
- * Use this function within constructor
59
- * @param targets
60
- */
61
- public inputNumberOnly(...targets: StringEditor[]): void {
62
- for (let i = 0; i < targets.length; i++) {
63
- targets[i].element.on('keypress', NumberOnly)
64
- }
65
- }
66
-
67
- private NumberOnly(e: Event): boolean {
68
- const ev = e as KeyboardEvent
69
- if ('0123456789'.includes(ev.key)) {
70
- return true
71
- }
72
-
73
- e.preventDefault()
74
- return false
75
- }
76
-
77
- public enabledEditItem<T>(form: T, ...targets: string[]): void {
78
- const frm = form as { [key: string]: object }
79
- for (let i = 0; i < targets.length; i++) {
80
- if (frm[targets[i]].constructor.name == 'LookupEditor') {
81
- ;(frm[targets[i]] as HTMLInputElement).readOnly = false
82
- } else {
83
- $(`input[name="${targets[i]}"]`).prop('disabled', false).removeClass('readonly')
84
- }
85
- }
86
- }
87
-
88
- public disabledEditItem<T>(form: T, ...targets: string[]): void {
89
- const frm = form as { [key: string]: object }
90
- for (let i = 0; i < targets.length; i++) {
91
- if (!frm[targets[i]]) {
92
- continue
93
- }
94
-
95
- if (frm[targets[i]].constructor.name == 'LookupEditor') {
96
- ;(frm[targets[i]] as HTMLInputElement).readOnly = true
97
- } else {
98
- $(`input[name="${targets[i]}"]`).prop('disabled', true).addClass('readonly')
99
- }
100
- }
101
- }
102
-
103
- public disabledAndClearEditItem<T>(form: T, ...targets: string[]): void {
104
- const frm = form as { [key: string]: object }
105
- for (let i = 0; i < targets.length; i++) {
106
- const className = frm[targets[i]].constructor.name
107
- if (className == 'LookupEditor') {
108
- ;(frm[targets[i]] as HTMLInputElement).readOnly = true
109
- } else {
110
- $(`input[name="${targets[i]}"]`).val('')
111
- $(`input[name="${targets[i]}"]`).addClass('readonly').prop('disabled', true)
112
- }
113
- }
114
- }
115
-
116
- /**
117
- * Use this function within function onDialogOpen()
118
- * Put after super.onDialogOpen() line
119
- * @param dialog
120
- * @param options
121
- */
122
- public setDialogSize(dialog: object, options?: IDialogSize) {
123
- let name = dialog.constructor.name
124
- name = `.s-${name}`
125
- const optionH = options?.height || 0
126
- const titleH = $(`${name} .ui-dialog-titlebar`).innerHeight() || 0
127
- const dialogH = $(`${name} .s-TemplatedDialog`).css('height', '').innerHeight() || 0
128
- const h = optionH > 0 ? optionH : titleH + dialogH + 2
129
- const w = options?.width ?? 420
130
- $(name)
131
- .css({ width: `${w}px`, height: `${h}px` })
132
- .position({
133
- of: window,
134
- my: 'center center',
135
- at: 'center center',
136
- })
137
- }
138
- }
139
-
140
- export type IDialogSize = {
141
- width?: number
142
- height?: number
143
- }
@@ -1,29 +0,0 @@
1
- import { deepClone, postToService } from '@serenity-is/corelib'
2
- import { IdevsExportOptions, IdevsExportRequest } from '../globals'
3
-
4
- export function doExportExcel(options: IdevsExportOptions): void {
5
- const grid = options.grid
6
- const request = deepClone(grid.getView().params) as IdevsExportRequest
7
- request.Take = 0
8
- request.Skip = 0
9
- const sortBy = grid.getView().sortBy
10
- if (sortBy) {
11
- request.Sort = sortBy
12
- }
13
-
14
- request.ExportColumns = []
15
- const columns = grid.getGrid().getColumns()
16
- for (const column of columns) {
17
- request.ExportColumns.push(column.id || column.field || '')
18
- }
19
- request.ExportColumns = request.ExportColumns.filter(column => !!column)
20
- request.viewName = options.viewName
21
- request.companyName = options.companyName
22
- request.reportName = options.reportName
23
- request.selectionRange = options.selectionRange
24
- request.conditionRange = options.conditionRange
25
- request.logo = options.logo
26
- request.entity = options.entity
27
-
28
- postToService({ service: options.service, request: request, target: '_blank' })
29
- }
@@ -1,107 +0,0 @@
1
- import { Column } from '@serenity-is/sleekgrid'
2
- import { indexOf, tryFirst } from '@serenity-is/corelib'
3
- import { EntityGrid, ToolButton } from '@serenity-is/corelib'
4
-
5
- /**
6
- * Use GetGridHelper within function layout()
7
- * Put the line before super.layout()
8
- * In case of master/detail form use this function within function getButtons() or getColumns()
9
- * @param helper
10
- * @constructor
11
- */
12
- export function GetGridHelper(helper: GridHelper): GridHelper {
13
- if (helper) {
14
- return helper
15
- }
16
-
17
- return new GridHelper()
18
- }
19
-
20
- export class GridHelper {
21
- /**
22
- * Use this function within function getColumns()
23
- * @param columns
24
- * @param removeColumns
25
- */
26
- public getColumns(columns: Column[], ...removeColumns: string[]): Column[] {
27
- for (const column of removeColumns) {
28
- columns.splice(
29
- indexOf(columns, c => c.field === column),
30
- 1,
31
- )
32
- }
33
-
34
- const id = tryFirst(columns, c => c.field === 'Id')
35
- if (id) {
36
- columns.splice(
37
- indexOf(columns, c => c.field === 'Id'),
38
- 1,
39
- )
40
- }
41
-
42
- return columns
43
- }
44
-
45
- /**
46
- * Use this function within function getButtons()
47
- * @param buttons
48
- * @param removeButtons
49
- */
50
- public getButtons(buttons: ToolButton[], ...removeButtons: string[]): ToolButton[] {
51
- for (const btn of removeButtons) {
52
- const id = indexOf(buttons, x => x.cssClass == btn)
53
- if (id >= 0) {
54
- buttons.splice(id, 1)
55
- }
56
- }
57
-
58
- return buttons
59
- }
60
-
61
- /**
62
- * Use this function within updateInterface method
63
- * Put below super.updateInterface() line
64
- * @param columns
65
- */
66
- public setHeaderAlignment(...columns: IHeaderAlignment[]): void {
67
- for (let c = 0; c < columns.length; c++) {
68
- const column: IHeaderAlignment = columns[c]
69
- const header = document.querySelector(`.slick-header-columns div[id$="${column.column}"] .slick-column-name`)
70
- if (header) {
71
- header.classList.add('text-center')
72
- }
73
- }
74
- }
75
-
76
- /**
77
- * Use this function within constructor
78
- * @param grid
79
- * @param options
80
- */
81
- public initGrid<TItem, TOptions>(grid: EntityGrid<TItem, TOptions>, options?: IInitGridOptions): void {
82
- // Set auto column width
83
- if (options?.autoColumnWidth ?? true) {
84
- const g = grid.getGrid()
85
- g.autosizeColumns()
86
- }
87
-
88
- // get dialog mode
89
- grid.openDialogsAsPanel = (options?.dialogMode ?? true) == false
90
- }
91
- }
92
-
93
- export type IInitGridOptions = {
94
- autoColumnWidth?: boolean
95
- dialogMode?: boolean
96
- }
97
-
98
- export type IHeaderAlignment = {
99
- column: string
100
- textAlign: HeaderTextAlignments
101
- }
102
-
103
- export enum HeaderTextAlignments {
104
- Left = 0,
105
- Center = 1,
106
- Right = 2,
107
- }
@@ -1,19 +0,0 @@
1
- declare module 'html2pdf.js' {
2
- type Html2PdfOptions = {
3
- margin?: number | [number, number, number, number]
4
- filename?: string
5
- image?: { type: string; quality: number }
6
- html2canvas?: { scale: number; logging: boolean; dpi: number; letterRendering: boolean }
7
- jsPDF?: { unit: string; format: string | number[]; orientation: string }
8
- }
9
-
10
- type Html2Pdf = {
11
- from(element: HTMLElement | string): Html2Pdf
12
- set(options: Html2PdfOptions): Html2Pdf
13
- toPdf(): Html2Pdf
14
- get(type: 'pdf'): Promise<jsPDF>
15
- }
16
-
17
- const html2pdf: () => Html2Pdf
18
- export = html2pdf
19
- }
@@ -1,4 +0,0 @@
1
- export * from './dialogHelper'
2
- export * from './gridHelper'
3
- export * from './excelExportHelper'
4
- export * from './pdfExportHelper'