mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-29 19:55:20 +00:00
TSK-1064: fix export csv in hr (#3032)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
ab479a93a0
commit
6356899a2a
@ -93,7 +93,7 @@ export class TDepartment extends TSpace implements Department {
|
|||||||
export class TDepartmentMember extends TEmployeeAccount implements DepartmentMember {}
|
export class TDepartmentMember extends TEmployeeAccount implements DepartmentMember {}
|
||||||
|
|
||||||
@Mixin(hr.mixin.Staff, contact.class.Employee)
|
@Mixin(hr.mixin.Staff, contact.class.Employee)
|
||||||
@UX(hr.string.Staff, hr.icon.HR)
|
@UX(hr.string.Staff, hr.icon.HR, 'STFF', 'name')
|
||||||
export class TStaff extends TEmployee implements Staff {
|
export class TStaff extends TEmployee implements Staff {
|
||||||
@Prop(TypeRef(hr.class.Department), hr.string.Department)
|
@Prop(TypeRef(hr.class.Department), hr.string.Department)
|
||||||
department!: Ref<Department>
|
department!: Ref<Department>
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
"Description": "Description",
|
"Description": "Description",
|
||||||
"MarkAsPublicHoliday": "Mark as public holiday",
|
"MarkAsPublicHoliday": "Mark as public holiday",
|
||||||
"EditPublicHoliday": "Edit public holiday",
|
"EditPublicHoliday": "Edit public holiday",
|
||||||
"Managers": "Managers"
|
"Managers": "Managers",
|
||||||
|
"Export": "Export",
|
||||||
|
"Separator": "Separator",
|
||||||
|
"ChooseSeparator": "Choose separator"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
"PublicHoliday": "Праздничный день",
|
"PublicHoliday": "Праздничный день",
|
||||||
"MarkAsPublicHoliday": "Отметить как праздничный день",
|
"MarkAsPublicHoliday": "Отметить как праздничный день",
|
||||||
"EditPublicHoliday": "Редактировать праздничный день",
|
"EditPublicHoliday": "Редактировать праздничный день",
|
||||||
"Managers": "Менеджера"
|
"Managers": "Менеджера",
|
||||||
|
"Export": "Экспортировать",
|
||||||
|
"Separator": "Разделитель",
|
||||||
|
"ChooseSeparator": "Выберите разделитель"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
<!--
|
||||||
|
// Copyright © 2023 Hardcore Engineering Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License. You may
|
||||||
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
//
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
-->
|
||||||
|
<script lang="ts">
|
||||||
|
import { Card } from '@hcengineering/presentation'
|
||||||
|
import { createEventDispatcher } from 'svelte'
|
||||||
|
import { DropdownLabelsIntl, Label } from '@hcengineering/ui'
|
||||||
|
import hr from '../../plugin'
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
export let items = []
|
||||||
|
|
||||||
|
let selectedSeparator = items[0].id
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
label={hr.string.Export}
|
||||||
|
okLabel={hr.string.Export}
|
||||||
|
okAction={() => dispatch('close', selectedSeparator)}
|
||||||
|
canSave
|
||||||
|
on:close
|
||||||
|
>
|
||||||
|
<div class="flex-row-center">
|
||||||
|
<Label label={hr.string.ChooseSeparator} />
|
||||||
|
<DropdownLabelsIntl {items} label={hr.string.Separator} bind:selected={selectedSeparator} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
@ -18,7 +18,7 @@
|
|||||||
import type { Request, RequestType, Staff } from '@hcengineering/hr'
|
import type { Request, RequestType, Staff } from '@hcengineering/hr'
|
||||||
import { getEmbeddedLabel } from '@hcengineering/platform'
|
import { getEmbeddedLabel } from '@hcengineering/platform'
|
||||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import { Button, Label, Loading, Scroller, tableSP, tableToCSV } from '@hcengineering/ui'
|
import { Button, Label, Loading, Scroller, showPopup, tableSP, tableToCSV } from '@hcengineering/ui'
|
||||||
import view, { BuildModelKey, Viewlet, ViewletPreference } from '@hcengineering/view'
|
import view, { BuildModelKey, Viewlet, ViewletPreference } from '@hcengineering/view'
|
||||||
import {
|
import {
|
||||||
getViewOptions,
|
getViewOptions,
|
||||||
@ -42,6 +42,7 @@
|
|||||||
import StatPresenter from './StatPresenter.svelte'
|
import StatPresenter from './StatPresenter.svelte'
|
||||||
import ReportPresenter from './ReportPresenter.svelte'
|
import ReportPresenter from './ReportPresenter.svelte'
|
||||||
import HolidayPresenter from './HolidayPresenter.svelte'
|
import HolidayPresenter from './HolidayPresenter.svelte'
|
||||||
|
import ExportPopup from './ExportPopup.svelte'
|
||||||
import { Department } from '@hcengineering/hr'
|
import { Department } from '@hcengineering/hr'
|
||||||
|
|
||||||
export let currentDate: Date = new Date()
|
export let currentDate: Date = new Date()
|
||||||
@ -355,7 +356,44 @@
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
function exportTable (evt: Event) {
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
id: '0',
|
||||||
|
label: getEmbeddedLabel(', (csv)'),
|
||||||
|
separator: ','
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
label: getEmbeddedLabel('; (MS Excel)'),
|
||||||
|
separator: ';'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
showPopup(
|
||||||
|
ExportPopup,
|
||||||
|
{
|
||||||
|
items
|
||||||
|
},
|
||||||
|
evt.target as HTMLElement,
|
||||||
|
(res) => {
|
||||||
|
if (res !== undefined) {
|
||||||
|
const filename = 'exportStaff' + new Date().toLocaleDateString() + '.csv'
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.style.display = 'none'
|
||||||
|
link.setAttribute('target', '_blank')
|
||||||
|
link.setAttribute(
|
||||||
|
'href',
|
||||||
|
'data:text/csv;charset=utf-8,%EF%BB%BF' +
|
||||||
|
encodeURIComponent(tableToCSV('exportableData', items[res].separator))
|
||||||
|
)
|
||||||
|
link.setAttribute('download', filename)
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
document.body.removeChild(link)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
$: viewOptions = getViewOptions(descr, $viewOptionStore)
|
$: viewOptions = getViewOptions(descr, $viewOptionStore)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -370,25 +408,7 @@
|
|||||||
<div class="ml-1">
|
<div class="ml-1">
|
||||||
<ViewletSettingButton bind:viewOptions viewlet={descr} />
|
<ViewletSettingButton bind:viewOptions viewlet={descr} />
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button label={getEmbeddedLabel('Export')} size={'small'} on:click={(evt) => exportTable(evt)} />
|
||||||
label={getEmbeddedLabel('Export')}
|
|
||||||
size={'small'}
|
|
||||||
on:click={() => {
|
|
||||||
// Download it
|
|
||||||
const filename = 'exportStaff' + new Date().toLocaleDateString() + '.csv'
|
|
||||||
const link = document.createElement('a')
|
|
||||||
link.style.display = 'none'
|
|
||||||
link.setAttribute('target', '_blank')
|
|
||||||
link.setAttribute(
|
|
||||||
'href',
|
|
||||||
'data:text/csv;charset=utf-8,%EF%BB%BF' + encodeURIComponent(tableToCSV('exportableData'))
|
|
||||||
)
|
|
||||||
link.setAttribute('download', filename)
|
|
||||||
document.body.appendChild(link)
|
|
||||||
link.click()
|
|
||||||
document.body.removeChild(link)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{#await createConfig(descr, preference, month) then config}
|
{#await createConfig(descr, preference, month) then config}
|
||||||
<Table
|
<Table
|
||||||
|
@ -51,6 +51,9 @@ export default mergeIds(hrId, hr, {
|
|||||||
Description: '' as IntlString,
|
Description: '' as IntlString,
|
||||||
MarkAsPublicHoliday: '' as IntlString,
|
MarkAsPublicHoliday: '' as IntlString,
|
||||||
EditPublicHoliday: '' as IntlString,
|
EditPublicHoliday: '' as IntlString,
|
||||||
Managers: '' as IntlString
|
Managers: '' as IntlString,
|
||||||
|
Export: '' as IntlString,
|
||||||
|
Separator: '' as IntlString,
|
||||||
|
ChooseSeparator: '' as IntlString
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user