mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 08:20:39 +00:00
Fix notification mark (#2908)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
b766ddf6de
commit
24762abaa9
@ -235,8 +235,7 @@ export function createModel (builder: Builder): void {
|
|||||||
label: notification.string.Inbox,
|
label: notification.string.Inbox,
|
||||||
icon: notification.icon.Notifications,
|
icon: notification.icon.Notifications,
|
||||||
alias: notificationId,
|
alias: notificationId,
|
||||||
position: 'bottom',
|
hidden: true,
|
||||||
hidden: false,
|
|
||||||
component: notification.component.Inbox
|
component: notification.component.Inbox
|
||||||
},
|
},
|
||||||
notification.app.Notification
|
notification.app.Notification
|
||||||
|
@ -19,20 +19,12 @@
|
|||||||
|
|
||||||
export let label: IntlString
|
export let label: IntlString
|
||||||
export let icon: Asset | AnySvelteComponent
|
export let icon: Asset | AnySvelteComponent
|
||||||
export let action: () => Promise<void>
|
export let selected: boolean = false
|
||||||
export let selected: boolean
|
|
||||||
export let mini: boolean = false
|
export let mini: boolean = false
|
||||||
export let notify: boolean
|
export let notify: boolean = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<button class="app" class:selected class:mini id={'app-' + label} use:tooltip={{ label }} on:click>
|
||||||
class="app"
|
|
||||||
class:selected
|
|
||||||
class:mini
|
|
||||||
id={'app-' + label}
|
|
||||||
use:tooltip={{ label }}
|
|
||||||
on:click|stopPropagation={action}
|
|
||||||
>
|
|
||||||
<div class="flex-center icon-container" class:mini class:noty={notify}>
|
<div class="flex-center icon-container" class:mini class:noty={notify}>
|
||||||
<Icon {icon} size={mini ? 'small' : 'large'} />
|
<Icon {icon} size={mini ? 'small' : 'large'} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,35 +15,36 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import calendar from '@hcengineering/calendar'
|
import calendar from '@hcengineering/calendar'
|
||||||
import contact, { Employee, EmployeeAccount } from '@hcengineering/contact'
|
import contact, { Employee, EmployeeAccount } from '@hcengineering/contact'
|
||||||
import core, { Class, Doc, getCurrentAccount, Ref, setCurrentAccount, Space } from '@hcengineering/core'
|
import core, { Class, Doc, Ref, Space, getCurrentAccount, setCurrentAccount } from '@hcengineering/core'
|
||||||
import notification, { NotificationStatus } from '@hcengineering/notification'
|
import login from '@hcengineering/login'
|
||||||
|
import notification, { notificationId } from '@hcengineering/notification'
|
||||||
import { BrowserNotificatator, NotificationClientImpl } from '@hcengineering/notification-resources'
|
import { BrowserNotificatator, NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||||
import { getMetadata, getResource, IntlString } from '@hcengineering/platform'
|
import { IntlString, getMetadata, getResource } from '@hcengineering/platform'
|
||||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import request, { RequestStatus } from '@hcengineering/request'
|
import request, { RequestStatus } from '@hcengineering/request'
|
||||||
import {
|
import {
|
||||||
AnyComponent,
|
AnyComponent,
|
||||||
areLocationsEqual,
|
|
||||||
closePanel,
|
|
||||||
closePopup,
|
|
||||||
closeTooltip,
|
|
||||||
Component,
|
Component,
|
||||||
DatePickerPopup,
|
DatePickerPopup,
|
||||||
deviceOptionsStore as deviceInfo,
|
|
||||||
Label,
|
Label,
|
||||||
location,
|
|
||||||
Location,
|
Location,
|
||||||
navigate,
|
|
||||||
NavLink,
|
NavLink,
|
||||||
openPanel,
|
|
||||||
PanelInstance,
|
PanelInstance,
|
||||||
Popup,
|
Popup,
|
||||||
PopupAlignment,
|
PopupAlignment,
|
||||||
PopupPosAlignment,
|
PopupPosAlignment,
|
||||||
resizeObserver,
|
|
||||||
ResolvedLocation,
|
ResolvedLocation,
|
||||||
showPopup,
|
TooltipInstance,
|
||||||
TooltipInstance
|
areLocationsEqual,
|
||||||
|
closePanel,
|
||||||
|
closePopup,
|
||||||
|
closeTooltip,
|
||||||
|
deviceOptionsStore as deviceInfo,
|
||||||
|
location,
|
||||||
|
navigate,
|
||||||
|
openPanel,
|
||||||
|
resizeObserver,
|
||||||
|
showPopup
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import view from '@hcengineering/view'
|
import view from '@hcengineering/view'
|
||||||
import { ActionContext, ActionHandler, migrateViewOpttions } from '@hcengineering/view-resources'
|
import { ActionContext, ActionHandler, migrateViewOpttions } from '@hcengineering/view-resources'
|
||||||
@ -52,17 +53,15 @@
|
|||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
import { subscribeMobile } from '../mobile'
|
import { subscribeMobile } from '../mobile'
|
||||||
import workbench from '../plugin'
|
import workbench from '../plugin'
|
||||||
|
import { workspacesStore } from '../utils'
|
||||||
import AccountPopup from './AccountPopup.svelte'
|
import AccountPopup from './AccountPopup.svelte'
|
||||||
import AppItem from './AppItem.svelte'
|
import AppItem from './AppItem.svelte'
|
||||||
import Applications from './Applications.svelte'
|
import Applications from './Applications.svelte'
|
||||||
import Settings from './icons/Settings.svelte'
|
|
||||||
import TopMenu from './icons/TopMenu.svelte'
|
|
||||||
import NavHeader from './NavHeader.svelte'
|
import NavHeader from './NavHeader.svelte'
|
||||||
import Navigator from './Navigator.svelte'
|
import Navigator from './Navigator.svelte'
|
||||||
import SpaceView from './SpaceView.svelte'
|
import SpaceView from './SpaceView.svelte'
|
||||||
import login from '@hcengineering/login'
|
import Settings from './icons/Settings.svelte'
|
||||||
import { workspacesStore } from '../utils'
|
import TopMenu from './icons/TopMenu.svelte'
|
||||||
import App from './App.svelte'
|
|
||||||
|
|
||||||
let contentPanel: HTMLElement
|
let contentPanel: HTMLElement
|
||||||
let shownMenu: boolean = false
|
let shownMenu: boolean = false
|
||||||
@ -143,14 +142,13 @@
|
|||||||
let hasNotification = false
|
let hasNotification = false
|
||||||
const notificationQuery = createQuery()
|
const notificationQuery = createQuery()
|
||||||
|
|
||||||
$: notificationQuery.query(
|
notificationQuery.query(
|
||||||
notification.class.Notification,
|
notification.class.DocUpdates,
|
||||||
{
|
{
|
||||||
attachedTo: account.employee,
|
user: account._id
|
||||||
status: { $nin: [NotificationStatus.Read] }
|
|
||||||
},
|
},
|
||||||
(res) => {
|
(res) => {
|
||||||
hasNotification = res.length > 0
|
hasNotification = res.some((p) => p.txes.length > 0)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -501,6 +499,8 @@
|
|||||||
return apps
|
return apps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let prevLoc: Location | undefined = undefined
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if employee?.active === true}
|
{#if employee?.active === true}
|
||||||
@ -538,9 +538,8 @@
|
|||||||
icon={TopMenu}
|
icon={TopMenu}
|
||||||
label={visibileNav ? workbench.string.HideMenu : workbench.string.ShowMenu}
|
label={visibileNav ? workbench.string.HideMenu : workbench.string.ShowMenu}
|
||||||
selected={!visibileNav}
|
selected={!visibileNav}
|
||||||
action={toggleNav}
|
on:click={toggleNav}
|
||||||
mini={appsMini}
|
mini={appsMini}
|
||||||
notify={false}
|
|
||||||
/>
|
/>
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<div class="thinButton" class:shownMenu on:click={() => (shownMenu = !shownMenu)}>
|
<div class="thinButton" class:shownMenu on:click={() => (shownMenu = !shownMenu)}>
|
||||||
@ -548,7 +547,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Applications
|
<Applications
|
||||||
apps={getApps(apps).filter((p) => p.position !== 'bottom')}
|
apps={getApps(apps)}
|
||||||
active={currentApplication?._id}
|
active={currentApplication?._id}
|
||||||
direction={appsDirection}
|
direction={appsDirection}
|
||||||
bind:shown={shownMenu}
|
bind:shown={shownMenu}
|
||||||
@ -557,26 +556,33 @@
|
|||||||
<AppItem
|
<AppItem
|
||||||
icon={request.icon.Requests}
|
icon={request.icon.Requests}
|
||||||
label={request.string.Requests}
|
label={request.string.Requests}
|
||||||
selected={false}
|
on:click={() => showPopup(request.component.RequestsPopup, {}, popupPosition)}
|
||||||
action={async () => {
|
|
||||||
showPopup(request.component.RequestsPopup, {}, popupPosition)
|
|
||||||
}}
|
|
||||||
notify={hasRequests}
|
notify={hasRequests}
|
||||||
/>
|
/>
|
||||||
<AppItem
|
<AppItem
|
||||||
icon={calendar.icon.Reminder}
|
icon={calendar.icon.Reminder}
|
||||||
label={calendar.string.Reminders}
|
label={calendar.string.Reminders}
|
||||||
selected={false}
|
on:click={() => showPopup(calendar.component.RemindersPopup, {}, popupPosition)}
|
||||||
action={async () => {
|
|
||||||
showPopup(calendar.component.RemindersPopup, {}, popupPosition)
|
|
||||||
}}
|
|
||||||
notify={false}
|
|
||||||
/>
|
/>
|
||||||
{#each getApps(apps).filter((p) => p.position === 'bottom') as app}
|
<NavLink app={notificationId}>
|
||||||
<NavLink app={app.alias}>
|
<AppItem
|
||||||
<App selected={app._id === currentApplication?._id} icon={app.icon} label={app.label} />
|
icon={notification.icon.Notifications}
|
||||||
</NavLink>
|
label={notification.string.Inbox}
|
||||||
{/each}
|
selected={currentAppAlias === notificationId}
|
||||||
|
on:click={(e) => {
|
||||||
|
if (currentAppAlias === notificationId) {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
if (prevLoc !== undefined) {
|
||||||
|
navigate(prevLoc)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prevLoc = $location
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
notify={hasNotification}
|
||||||
|
/>
|
||||||
|
</NavLink>
|
||||||
<div class="flex-center" class:mt-2={appsDirection === 'vertical'} class:ml-2={appsDirection === 'horizontal'}>
|
<div class="flex-center" class:mt-2={appsDirection === 'vertical'} class:ml-2={appsDirection === 'horizontal'}>
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<div
|
<div
|
||||||
|
@ -28,7 +28,6 @@ export interface Application extends Doc {
|
|||||||
alias: string
|
alias: string
|
||||||
icon: Asset
|
icon: Asset
|
||||||
hidden: boolean
|
hidden: boolean
|
||||||
position?: 'top' | 'bottom'
|
|
||||||
navigatorModel?: NavigatorModel
|
navigatorModel?: NavigatorModel
|
||||||
locationResolver?: Resource<(loc: Location) => Promise<ResolvedLocation | undefined>>
|
locationResolver?: Resource<(loc: Location) => Promise<ResolvedLocation | undefined>>
|
||||||
|
|
||||||
|
@ -389,8 +389,13 @@ export async function OnUpdateLastView (tx: Tx, control: TriggerControl): Promis
|
|||||||
if (actualTx._class !== core.class.TxUpdateDoc) return []
|
if (actualTx._class !== core.class.TxUpdateDoc) return []
|
||||||
if (actualTx.objectClass !== notification.class.LastView) return []
|
if (actualTx.objectClass !== notification.class.LastView) return []
|
||||||
const result: Tx[] = []
|
const result: Tx[] = []
|
||||||
|
const lastView = (await control.findAll(notification.class.LastView, { _id: actualTx.objectId }))[0]
|
||||||
|
if (lastView === undefined) return result
|
||||||
for (const key in actualTx.operations) {
|
for (const key in actualTx.operations) {
|
||||||
const docs = await control.findAll(notification.class.DocUpdates, { attachedTo: key as Ref<Doc> })
|
const docs = await control.findAll(notification.class.DocUpdates, {
|
||||||
|
attachedTo: key as Ref<Doc>,
|
||||||
|
user: lastView.user
|
||||||
|
})
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
const txes = doc.txes.filter((p) => p[1] > actualTx.operations[key])
|
const txes = doc.txes.filter((p) => p[1] > actualTx.operations[key])
|
||||||
result.push(
|
result.push(
|
||||||
|
Loading…
Reference in New Issue
Block a user