Skip to content

Commit 62dfae9

Browse files
authored
viewlet fixes (#7934)
Signed-off-by: Denis Bykhov <[email protected]>
1 parent 2d10797 commit 62dfae9

File tree

4 files changed

+68
-52
lines changed

4 files changed

+68
-52
lines changed

Diff for: models/drive/src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ function defineResource (builder: Builder): void {
349349
key: '',
350350
presenter: drive.component.ResourcePresenter,
351351
label: drive.string.Name,
352-
sortingKey: 'name'
352+
sortingKey: 'title'
353353
},
354354
'$lookup.file.size',
355355
'comments',
@@ -366,7 +366,7 @@ function defineResource (builder: Builder): void {
366366
}
367367
} as FindOptions<Resource>,
368368
configOptions: {
369-
hiddenKeys: ['name', 'parent', 'path', 'file', 'versions'],
369+
hiddenKeys: ['title', 'parent', 'path', 'file', 'versions'],
370370
sortable: true
371371
}
372372
},
@@ -393,7 +393,7 @@ function defineResource (builder: Builder): void {
393393
viewOptions: {
394394
groupBy: [],
395395
orderBy: [
396-
['name', SortingOrder.Ascending],
396+
['title', SortingOrder.Ascending],
397397
['$lookup.file.size', SortingOrder.Ascending],
398398
['$lookup.file.modifiedOn', SortingOrder.Descending]
399399
],
@@ -404,14 +404,14 @@ function defineResource (builder: Builder): void {
404404
key: '',
405405
presenter: drive.component.ResourcePresenter,
406406
label: drive.string.Name,
407-
sortingKey: 'name'
407+
sortingKey: 'title'
408408
},
409409
'$lookup.file.size',
410410
'$lookup.file.modifiedOn',
411411
'createdBy'
412412
],
413413
configOptions: {
414-
hiddenKeys: ['name', 'parent', 'path', 'file', 'versions'],
414+
hiddenKeys: ['title', 'parent', 'path', 'file', 'versions'],
415415
sortable: true
416416
},
417417
/* eslint-disable @typescript-eslint/consistent-type-assertions */

Diff for: plugins/tracker-resources/src/components/NewIssueHeader.svelte

+49-26
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<script lang="ts">
1616
import { Analytics } from '@hcengineering/analytics'
1717
import { AccountRole, Ref, Space, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
18-
import { MultipleDraftController, getClient } from '@hcengineering/presentation'
18+
import { MultipleDraftController, createQuery, getClient } from '@hcengineering/presentation'
1919
import { TrackerEvents } from '@hcengineering/tracker'
20-
import { ButtonWithDropdown, IconAdd, IconDropdown, SelectPopupValueType, showPopup } from '@hcengineering/ui'
20+
import { Button, ButtonWithDropdown, IconAdd, IconDropdown, SelectPopupValueType, showPopup } from '@hcengineering/ui'
2121
import view from '@hcengineering/view'
2222
2323
import { onDestroy } from 'svelte'
@@ -44,6 +44,14 @@
4444
})
4545
}
4646
47+
const query = createQuery()
48+
49+
let projectExists = false
50+
51+
query.query(tracker.class.Project, {}, (res) => {
52+
projectExists = res.length > 0
53+
})
54+
4755
$: label = draftExists || !closed ? tracker.string.ResumeDraft : tracker.string.NewIssue
4856
$: dropdownItems = hasAccountRole(getCurrentAccount(), AccountRole.User)
4957
? [
@@ -86,30 +94,45 @@
8694
</script>
8795

8896
<div class="antiNav-subheader">
89-
<ButtonWithDropdown
90-
icon={IconAdd}
91-
justify={'left'}
92-
kind={'primary'}
93-
{label}
94-
on:click={newIssue}
95-
{dropdownItems}
96-
dropdownIcon={IconDropdown}
97-
on:dropdown-selected={(ev) => {
98-
dropdownItemSelected(ev.detail)
99-
}}
100-
mainButtonId={'new-issue'}
101-
showTooltipMain={{
102-
direction: 'bottom',
103-
label,
104-
keys
105-
}}
106-
>
107-
<div slot="content" class="draft-circle-container">
108-
{#if draftExists}
109-
<div class="draft-circle" />
110-
{/if}
111-
</div>
112-
</ButtonWithDropdown>
97+
{#if projectExists}
98+
<ButtonWithDropdown
99+
icon={IconAdd}
100+
justify={'left'}
101+
kind={'primary'}
102+
{label}
103+
on:click={newIssue}
104+
{dropdownItems}
105+
dropdownIcon={IconDropdown}
106+
on:dropdown-selected={(ev) => {
107+
dropdownItemSelected(ev.detail)
108+
}}
109+
mainButtonId={'new-issue'}
110+
showTooltipMain={{
111+
direction: 'bottom',
112+
label,
113+
keys
114+
}}
115+
>
116+
<div slot="content" class="draft-circle-container">
117+
{#if draftExists}
118+
<div class="draft-circle" />
119+
{/if}
120+
</div>
121+
</ButtonWithDropdown>
122+
{:else}
123+
<Button
124+
icon={IconAdd}
125+
justify="left"
126+
kind="primary"
127+
label={tracker.string.CreateProject}
128+
width="100%"
129+
on:click={() => {
130+
showPopup(tracker.component.CreateProject, {}, 'top', () => {
131+
closed = true
132+
})
133+
}}
134+
/>
135+
{/if}
113136
</div>
114137

115138
<style lang="scss">

Diff for: plugins/tracker-resources/src/index.ts

+8-19
Original file line numberDiff line numberDiff line change
@@ -326,25 +326,14 @@ async function deleteProject (project: Project | undefined): Promise<void> {
326326
})
327327
} else {
328328
const anyIssue = await client.findOne(tracker.class.Issue, { space: project._id })
329-
if (anyIssue !== undefined) {
330-
showPopup(MessageBox, {
331-
label: tracker.string.ArchiveProjectName,
332-
labelProps: { name: project.name },
333-
message: tracker.string.ProjectHasIssues,
334-
action: async () => {
335-
await client.update(project, { archived: true })
336-
}
337-
})
338-
} else {
339-
showPopup(MessageBox, {
340-
label: tracker.string.ArchiveProjectName,
341-
labelProps: { name: project.name },
342-
message: tracker.string.ArchiveProjectConfirm,
343-
action: async () => {
344-
await client.update(project, { archived: true })
345-
}
346-
})
347-
}
329+
showPopup(MessageBox, {
330+
label: tracker.string.ArchiveProjectName,
331+
labelProps: { name: project.name },
332+
message: anyIssue !== undefined ? tracker.string.ProjectHasIssues : tracker.string.ArchiveProjectConfirm,
333+
action: async () => {
334+
await client.update(project, { archived: true })
335+
}
336+
})
348337
}
349338
}
350339
}

Diff for: plugins/view-resources/src/components/ViewletContentView.svelte

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@
4242
(res) => {
4343
configurationRaw = res
4444
configurationsLoading = false
45+
loading = configurationsLoading || preferencesLoading
4546
}
4647
)
4748
}
4849
49-
function fetchPreferences (viewlet: Viewlet): void {
50+
function fetchPreferences (configurationRaw: Viewlet[]): void {
5051
preferencesLoading = preferenceQuery.query(
5152
view.class.ViewletPreference,
5253
{
@@ -56,6 +57,7 @@
5657
(res) => {
5758
preference = res
5859
preferencesLoading = false
60+
loading = configurationsLoading || preferencesLoading
5961
}
6062
)
6163
}
@@ -81,7 +83,7 @@
8183
}
8284
8385
$: fetchConfigurations(viewlet)
84-
$: fetchPreferences(viewlet)
86+
$: fetchPreferences(configurationRaw)
8587
8688
$: updateConfiguration(configurationRaw, preference)
8789
@@ -90,6 +92,8 @@
9092

9193
{#if viewlet?.$lookup?.descriptor?.component}
9294
{#if loading}
95+
{configurationsLoading}
96+
{preferencesLoading}
9397
<Loading />
9498
{:else}
9599
<Component

0 commit comments

Comments
 (0)