mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
TSK-418: Added working day option (#2393)
Signed-off-by: Anton Brechka <anton.brechka@xored.com>
This commit is contained in:
parent
3578f2b90d
commit
34c3d07e5c
@ -39,6 +39,7 @@
|
||||
"NoActionsDefined": "No actions applicable",
|
||||
"Incoming": "Incoming",
|
||||
"HoursLabel": "Hours",
|
||||
"Back": "Back"
|
||||
"Back": "Back",
|
||||
"DropdownDefaultLabel": "Select Item"
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
"NoActionsDefined": "Нет доступных действий",
|
||||
"Incoming": "Входящие",
|
||||
"HoursLabel": "Часы",
|
||||
"Back": "Назад"
|
||||
"Back": "Назад",
|
||||
"DropdownDefaultLabel": "Выберите Элемент"
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,10 @@
|
||||
import Button from './Button.svelte'
|
||||
import DropdownLabelsPopupIntl from './DropdownLabelsPopupIntl.svelte'
|
||||
import Label from './Label.svelte'
|
||||
import ui from '../plugin'
|
||||
|
||||
export let icon: Asset | AnySvelteComponent | undefined = undefined
|
||||
export let label: IntlString
|
||||
export let label: IntlString = ui.string.DropdownDefaultLabel
|
||||
export let items: DropdownIntlItem[]
|
||||
export let selected: DropdownIntlItem['id'] | undefined = undefined
|
||||
export let disabled: boolean = false
|
||||
@ -33,12 +34,13 @@
|
||||
export let justify: 'left' | 'center' = 'center'
|
||||
export let width: string | undefined = undefined
|
||||
export let labelDirection: TooltipAlignment | undefined = undefined
|
||||
export let shouldUpdateUndefined: boolean = true
|
||||
|
||||
let container: HTMLElement
|
||||
let opened: boolean = false
|
||||
|
||||
$: selectedItem = items.find((x) => x.id === selected)
|
||||
$: if (selected === undefined && items[0] !== undefined) {
|
||||
$: if (shouldUpdateUndefined && selected === undefined && items[0] !== undefined) {
|
||||
selected = items[0].id
|
||||
dispatch('selected', selected)
|
||||
}
|
||||
|
@ -117,7 +117,8 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="editbox-container w-full"
|
||||
class="editbox-container"
|
||||
class:w-full={focusable}
|
||||
on:click={() => {
|
||||
input.focus()
|
||||
}}
|
||||
|
@ -64,7 +64,8 @@ export const uis = plugin(uiId, {
|
||||
NoActionsDefined: '' as IntlString,
|
||||
Incoming: '' as IntlString,
|
||||
HoursLabel: '' as IntlString,
|
||||
Back: '' as IntlString
|
||||
Back: '' as IntlString,
|
||||
DropdownDefaultLabel: '' as IntlString
|
||||
},
|
||||
metadata: {
|
||||
DefaultApplication: '' as Metadata<AnyComponent>,
|
||||
|
@ -245,7 +245,11 @@
|
||||
"SaveProcess": "Save Process",
|
||||
"NoIssueTemplate": "No Process",
|
||||
"TemplateReplace": "You you replace applied process?",
|
||||
"TemplateReplaceConfirm": "All changes to template values will be lost."
|
||||
"TemplateReplaceConfirm": "All changes to template values will be lost.",
|
||||
|
||||
"WorkDayCurrent": "Current Working Day",
|
||||
"WorkDayPrevious": "Previous Working Day",
|
||||
"WorkDayLabel": "Select Working Day Type"
|
||||
},
|
||||
"status": {}
|
||||
}
|
||||
|
@ -245,7 +245,11 @@
|
||||
"SaveProcess": "Сохранить процесс",
|
||||
"NoIssueTemplate": "Без процесса",
|
||||
"TemplateReplace": "Вы хотите заменить выбранный процесс?",
|
||||
"TemplateReplaceConfirm": "Все внесенные изменения в задачу будут потеряны"
|
||||
"TemplateReplaceConfirm": "Все внесенные изменения в задачу будут потеряны",
|
||||
|
||||
"WorkDayCurrent": "Текущий Рабочий День",
|
||||
"WorkDayPrevious": "Предыдущий Рабочий День",
|
||||
"WorkDayLabel": "Выберите Тип Рабочего Дня"
|
||||
},
|
||||
"status": {}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
import { Issue, TimeSpendReport } from '@hcengineering/tracker'
|
||||
import { DatePresenter, EditBox } from '@hcengineering/ui'
|
||||
import tracker from '../../../plugin'
|
||||
import { getWorkDate, WorkDaysType } from '../../../utils'
|
||||
import WorkDaysDropdown from './WorkDaysDropdown.svelte'
|
||||
|
||||
export let issueId: Ref<Issue>
|
||||
export let issueClass: Ref<Class<Issue>>
|
||||
@ -34,7 +36,7 @@
|
||||
}
|
||||
|
||||
const data = {
|
||||
date: value?.date ?? Date.now(),
|
||||
date: value?.date ?? getWorkDate(WorkDaysType.PREVIOUS),
|
||||
description: value?.description ?? '',
|
||||
value: value?.value,
|
||||
employee: value?.employee ?? assignee ?? null
|
||||
@ -86,6 +88,7 @@
|
||||
bind:value={data.employee}
|
||||
showNavigate={false}
|
||||
/>
|
||||
<WorkDaysDropdown bind:dateTimestamp={data.date} />
|
||||
<DatePresenter kind={'link'} bind:value={data.date} editable />
|
||||
</div>
|
||||
<EditBox bind:value={data.description} placeholder={tracker.string.TimeSpendReportDescription} kind={'editbox'} />
|
||||
|
@ -0,0 +1,46 @@
|
||||
<!--
|
||||
// Copyright © 2022 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 { DropdownIntlItem, DropdownLabelsIntl } from '@hcengineering/ui'
|
||||
import tracker from '../../../plugin'
|
||||
import { WorkDaysType } from '../../../types'
|
||||
import { getWorkDate, getWorkDayType } from '../../../utils'
|
||||
import WorkDaysIcon from './WorkDaysIcon.svelte'
|
||||
|
||||
export let dateTimestamp: number
|
||||
|
||||
const workDaysDropdownItems: DropdownIntlItem[] = [
|
||||
{
|
||||
id: WorkDaysType.CURRENT,
|
||||
label: tracker.string.WorkDayCurrent
|
||||
},
|
||||
{
|
||||
id: WorkDaysType.PREVIOUS,
|
||||
label: tracker.string.WorkDayPrevious
|
||||
}
|
||||
]
|
||||
|
||||
$: selectedWorkDayType = dateTimestamp ? getWorkDayType(dateTimestamp) : undefined
|
||||
</script>
|
||||
|
||||
<DropdownLabelsIntl
|
||||
kind="link-bordered"
|
||||
icon={WorkDaysIcon}
|
||||
shouldUpdateUndefined={false}
|
||||
label={tracker.string.WorkDayLabel}
|
||||
items={workDaysDropdownItems}
|
||||
bind:selected={selectedWorkDayType}
|
||||
on:selected={({ detail }) => (dateTimestamp = getWorkDate(detail))}
|
||||
/>
|
@ -0,0 +1,19 @@
|
||||
<script lang="ts">
|
||||
export let size: 'x-small' | 'small' | 'medium' | 'large' | 'full'
|
||||
export let fill: string = 'currentColor'
|
||||
</script>
|
||||
|
||||
<svg class="svg-{size}" {fill} viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M9.827 10.735l-1.744 -0.803l-0.838 -0.707l-1.34 1.333l0.578 3.863c0.002 0.013 -0.001 0.027 -0.009 0.038l-0.611 0.837c-0.01 0.013 -0.025 0.021 -0.042 0.021s-0.032 -0.008 -0.042 -0.021l-0.611 -0.837c-0.008 -0.011 -0.011 -0.025 -0.009 -0.038l0.578 -3.863l-1.34 -1.333l-0.838 0.707l-1.744 0.803c-0.258 0.106 -0.509 0.265 -0.641 0.547c0 0 -1.896 4.513 -0.867 4.513h11.029c1.028 0 -0.867 -4.513 -0.867 -4.513C10.355 11.013 10.085 10.841 9.827 10.735z"
|
||||
/>
|
||||
<path
|
||||
d="M5.82 9.2c1.784 0 3.115 -1.662 3.145 -4.449c0.019 -1.934 -0.902 -3.091 -3.145 -3.091c-2.243 0 -3.165 1.157 -3.145 3.091C2.705 7.538 4.036 9.2 5.82 9.2z"
|
||||
/>
|
||||
<path
|
||||
d="M11.894 0.205c-1.319 0 -2.495 0.626 -3.247 1.595c0.078 0.064 0.152 0.131 0.223 0.202c0.139 0.141 0.263 0.296 0.371 0.464c0.585 -0.838 1.556 -1.387 2.653 -1.387c1.782 0 3.232 1.45 3.232 3.232c0 1.782 -1.45 3.232 -3.232 3.232c-0.893 0 -1.702 -0.364 -2.288 -0.951c-0.078 0.321 -0.177 0.624 -0.296 0.908c0.706 0.573 1.606 0.918 2.584 0.918c2.264 0 4.106 -1.842 4.106 -4.106C16 2.047 14.158 0.205 11.894 0.205z"
|
||||
/>
|
||||
<path
|
||||
d="M11.894 1.694c-0.181 0 -0.328 0.147 -0.328 0.328v2.403c0 0.181 0.147 0.328 0.328 0.328h1.905c0.181 0 0.328 -0.147 0.328 -0.328c0 -0.181 -0.147 -0.328 -0.328 -0.328h-1.577V2.022C12.222 1.841 12.075 1.694 11.894 1.694z"
|
||||
/>
|
||||
</svg>
|
@ -261,7 +261,11 @@ export default mergeIds(trackerId, tracker, {
|
||||
SaveProcess: '' as IntlString,
|
||||
NoIssueTemplate: '' as IntlString,
|
||||
TemplateReplace: '' as IntlString,
|
||||
TemplateReplaceConfirm: '' as IntlString
|
||||
TemplateReplaceConfirm: '' as IntlString,
|
||||
|
||||
WorkDayCurrent: '' as IntlString,
|
||||
WorkDayPrevious: '' as IntlString,
|
||||
WorkDayLabel: '' as IntlString
|
||||
},
|
||||
component: {
|
||||
NopeComponent: '' as AnyComponent,
|
||||
|
@ -104,3 +104,8 @@ export const issuesGroupBySorting: Record<IssuesGrouping, SortingQuery<Issue>> =
|
||||
[IssuesGrouping.Sprint]: { '$lookup.sprint.label': SortingOrder.Ascending },
|
||||
[IssuesGrouping.NoGrouping]: {}
|
||||
}
|
||||
|
||||
export enum WorkDaysType {
|
||||
CURRENT = 'current',
|
||||
PREVIOUS = 'previous'
|
||||
}
|
||||
|
@ -33,12 +33,19 @@ import { ViewOptionModel } from '@hcengineering/view-resources'
|
||||
import {
|
||||
AnyComponent,
|
||||
AnySvelteComponent,
|
||||
areDatesEqual,
|
||||
getMillisecondsInMonth,
|
||||
isWeekend,
|
||||
MILLISECONDS_IN_WEEK
|
||||
} from '@hcengineering/ui'
|
||||
import tracker from './plugin'
|
||||
import { defaultPriorities, defaultProjectStatuses, defaultSprintStatuses, issuePriorities } from './types'
|
||||
import {
|
||||
defaultPriorities,
|
||||
defaultProjectStatuses,
|
||||
defaultSprintStatuses,
|
||||
issuePriorities,
|
||||
WorkDaysType
|
||||
} from './types'
|
||||
|
||||
export * from './types'
|
||||
|
||||
@ -641,3 +648,29 @@ export async function moveIssuesToAnotherSprint (
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function getWorkDate (type: WorkDaysType): number {
|
||||
const date = new Date(Date.now())
|
||||
if (type === WorkDaysType.PREVIOUS) {
|
||||
date.setDate(date.getDate() - 1)
|
||||
}
|
||||
|
||||
// if currentDate is day off then set date to last working day
|
||||
while (isWeekend(date)) {
|
||||
date.setDate(date.getDate() - 1)
|
||||
}
|
||||
|
||||
return date.valueOf()
|
||||
}
|
||||
|
||||
export function getWorkDayType (timestamp: number): WorkDaysType | undefined {
|
||||
const date = new Date(timestamp)
|
||||
const currentWorkDate = new Date(getWorkDate(WorkDaysType.CURRENT))
|
||||
const previousWorkDate = new Date(getWorkDate(WorkDaysType.PREVIOUS))
|
||||
|
||||
if (areDatesEqual(date, currentWorkDate)) {
|
||||
return WorkDaysType.CURRENT
|
||||
} else if (areDatesEqual(date, previousWorkDate)) {
|
||||
return WorkDaysType.PREVIOUS
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user