Skip to content

Commit da0da6b

Browse files
authored
UBERF-8564 More readonly fields in guest mode (#7076)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
1 parent 6962e80 commit da0da6b

File tree

10 files changed

+79
-49
lines changed

10 files changed

+79
-49
lines changed

plugins/contact-resources/src/components/AssigneeBox.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
{getName(client.getHierarchy(), selected)}
185185
{/if}
186186
{:else}
187-
<div class="flex-presenter not-selected">
187+
<div class="flex-presenter not-selected" class:cursor-default={readonly}>
188188
{#if icon}
189189
<div class="icon w-4 flex-no-shrink" class:small-gap={size === 'inline' || size === 'small'}>
190190
<Icon {icon} size={'small'} />

plugins/contact-resources/src/components/EditOrganizationPanel.svelte

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
on:close={() => {
9898
dispatch('close')
9999
}}
100+
withoutInput={readonly}
100101
>
101102
<svelte:fragment slot="title">
102103
<DocNavLink noUnderline {object}>
@@ -106,7 +107,7 @@
106107

107108
<svelte:fragment slot="attributes" let:direction={dir}>
108109
{#if dir === 'column'}
109-
<DocAttributeBar {object} {mixins} {ignoreKeys} />
110+
<DocAttributeBar {object} {mixins} {ignoreKeys} {readonly} />
110111
{/if}
111112
</svelte:fragment>
112113

@@ -117,14 +118,16 @@
117118
</svelte:fragment>
118119

119120
<svelte:fragment slot="utils">
120-
<Button
121-
icon={IconMoreH}
122-
iconProps={{ size: 'medium' }}
123-
kind={'icon'}
124-
on:click={(e) => {
125-
showMenu(e, { object, excludedActions: [view.action.Open] })
126-
}}
127-
/>
121+
{#if !readonly}
122+
<Button
123+
icon={IconMoreH}
124+
iconProps={{ size: 'medium' }}
125+
kind={'icon'}
126+
on:click={(e) => {
127+
showMenu(e, { object, excludedActions: [view.action.Open] })
128+
}}
129+
/>
130+
{/if}
128131
<Button
129132
icon={IconMixin}
130133
kind={'icon'}
@@ -137,14 +140,15 @@
137140
</svelte:fragment>
138141

139142
<div class="flex-col flex-grow flex-no-shrink step-tb-6">
140-
<EditOrganization {object} />
143+
<EditOrganization {object} {readonly} />
141144
<div class="flex-col flex-grow w-full mt-6 relative">
142145
<AttachmentStyleBoxCollabEditor
143146
focusIndex={30}
144147
{object}
145148
key={{ key: 'description', attr: descriptionKey }}
146149
placeholder={core.string.Description}
147150
enableAttachments={false}
151+
{readonly}
148152
on:saved={(evt) => {
149153
saved = evt.detail
150154
}}

plugins/contact-resources/src/components/UserBoxList.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
{kind}
104104
{size}
105105
{justify}
106+
disabled={readonly}
106107
showTooltip={label ? { label, direction: labelDirection } : undefined}
107108
on:click={addPerson}
108109
>

plugins/recruit-resources/src/components/Applications.svelte

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import SectionEmpty from './SectionEmpty.svelte'
2525
2626
export let objectId: Ref<Doc>
27-
2827
export let applications: number
28+
export let readonly: boolean = false
2929
3030
const createApp = (ev: MouseEvent): void => {
3131
showPopup(CreateApplication, { candidate: objectId, preserveCandidate: true }, ev.target as HTMLElement)
@@ -46,7 +46,9 @@
4646
bind:loading
4747
bind:preference
4848
/>
49-
<Button id="appls.add" icon={IconAdd} kind={'ghost'} on:click={createApp} />
49+
{#if !readonly}
50+
<Button id="appls.add" icon={IconAdd} kind={'ghost'} on:click={createApp} />
51+
{/if}
5052
</div>
5153
</svelte:fragment>
5254

@@ -58,15 +60,18 @@
5860
config={preference?.config ?? viewlet.config}
5961
query={{ attachedTo: objectId, ...(viewlet?.baseQuery ?? {}) }}
6062
loadingProps={{ length: applications }}
63+
{readonly}
6164
/>
6265
</Scroller>
6366
{:else}
6467
<SectionEmpty icon={FileDuo} label={recruit.string.NoApplicationsForTalent}>
65-
<!-- svelte-ignore a11y-click-events-have-key-events -->
66-
<!-- svelte-ignore a11y-no-static-element-interactions -->
67-
<span class="over-underline content-color" on:click={createApp}>
68-
<Label label={recruit.string.CreateAnApplication} />
69-
</span>
68+
{#if !readonly}
69+
<!-- svelte-ignore a11y-click-events-have-key-events -->
70+
<!-- svelte-ignore a11y-no-static-element-interactions -->
71+
<span class="over-underline content-color" on:click={createApp}>
72+
<Label label={recruit.string.CreateAnApplication} />
73+
</span>
74+
{/if}
7075
</SectionEmpty>
7176
{/if}
7277
</svelte:fragment>

plugins/recruit-resources/src/components/EditVacancy.svelte

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
3232
export let _id: Ref<Vacancy>
3333
export let embedded: boolean = false
34+
export let readonly = false
3435
3536
let object: Required<Vacancy>
3637
let rawName: string = ''
@@ -140,6 +141,7 @@
140141
<DocAttributeBar
141142
{object}
142143
{mixins}
144+
{readonly}
143145
ignoreKeys={['name', 'fullDescription', 'private', 'archived', 'type', 'owners']}
144146
/>
145147
{/if}
@@ -151,6 +153,7 @@
151153
kind={'large-style'}
152154
focusable
153155
autoFocus={!embedded}
156+
disabled={readonly}
154157
on:blur={save}
155158
/>
156159

@@ -160,14 +163,16 @@
160163
{/if}
161164
</svelte:fragment>
162165
<svelte:fragment slot="utils">
163-
<Button
164-
icon={IconMoreH}
165-
iconProps={{ size: 'medium' }}
166-
kind={'icon'}
167-
on:click={(e) => {
168-
showMenu(e, { object, excludedActions: [view.action.Open] })
169-
}}
170-
/>
166+
{#if !readonly}
167+
<Button
168+
icon={IconMoreH}
169+
iconProps={{ size: 'medium' }}
170+
kind={'icon'}
171+
on:click={(e) => {
172+
showMenu(e, { object, excludedActions: [view.action.Open] })
173+
}}
174+
/>
175+
{/if}
171176
<Button
172177
icon={IconMixin}
173178
kind={'icon'}
@@ -187,14 +192,15 @@
187192
key={{ key: 'fullDescription', attr: descriptionKey }}
188193
bind:this={descriptionBox}
189194
placeholder={recruit.string.FullDescription}
195+
{readonly}
190196
on:saved={(evt) => {
191197
saved = evt.detail
192198
}}
193199
/>
194200
</div>
195201

196202
<div class="w-full mt-6">
197-
<VacancyApplications objectId={object._id} />
203+
<VacancyApplications objectId={object._id} {readonly} />
198204
</div>
199205
<div class="w-full mt-6">
200206
<Component is={tracker.component.RelatedIssuesSection} props={{ object, label: tracker.string.RelatedIssues }} />

plugins/recruit-resources/src/components/VacancyApplications.svelte

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import SectionEmpty from './SectionEmpty.svelte'
2727
2828
export let objectId: Ref<Vacancy>
29+
export let readonly = false
2930
let applications: number
3031
3132
const query = createQuery()
@@ -60,7 +61,9 @@
6061
bind:preference
6162
bind:loading
6263
/>
63-
<Button id="appls.add" icon={IconAdd} kind={'ghost'} on:click={createApp} />
64+
{#if !readonly}
65+
<Button id="appls.add" icon={IconAdd} kind={'ghost'} on:click={createApp} />
66+
{/if}
6467
</div>
6568
</div>
6669
{#if applications > 0}
@@ -71,6 +74,7 @@
7174
config={preference?.config ?? viewlet.config}
7275
query={{ space: objectId }}
7376
loadingProps={{ length: applications }}
77+
{readonly}
7478
/>
7579
</Scroller>
7680
{:else}
@@ -80,9 +84,11 @@
8084
<SectionEmpty icon={FileDuo} label={recruit.string.NoApplicationsForVacancy}>
8185
<!-- svelte-ignore a11y-click-events-have-key-events -->
8286
<!-- svelte-ignore a11y-no-static-element-interactions -->
83-
<span class="over-underline content-color" on:click={createApp}>
84-
<Label label={recruit.string.CreateAnApplication} />
85-
</span>
87+
{#if !readonly}
88+
<span class="over-underline content-color" on:click={createApp}>
89+
<Label label={recruit.string.CreateAnApplication} />
90+
</span>
91+
{/if}
8692
</SectionEmpty>
8793
{/if}
8894
</div>

plugins/recruit-resources/src/components/VacancyList.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@
7272
</Scroller>
7373
{:else}
7474
<SectionEmpty icon={FileDuo} label={recruit.string.NoVacancies}>
75-
<!-- svelte-ignore a11y-click-events-have-key-events -->
76-
<!-- svelte-ignore a11y-no-static-element-interactions -->
77-
<span class="over-underline content-color" on:click={createApp}>
78-
<Label label={recruit.string.CreateVacancy} />
79-
</span>
75+
{#if !readonly}
76+
<!-- svelte-ignore a11y-click-events-have-key-events -->
77+
<!-- svelte-ignore a11y-no-static-element-interactions -->
78+
<span class="over-underline content-color" on:click={createApp}>
79+
<Label label={recruit.string.CreateVacancy} />
80+
</span>
81+
{/if}
8082
</SectionEmpty>
8183
{/if}
8284
</div>

plugins/tags-resources/src/components/Tags.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
export let object: Doc
2323
export let _class: Ref<Class<Doc>>
2424
export let key: KeyedAttribute
25+
export let readonly: boolean = false
2526
2627
const client = getClient()
2728
@@ -56,6 +57,7 @@
5657

5758
<TagsEditor
5859
{key}
60+
{readonly}
5961
bind:items
6062
targetClass={_class}
6163
on:open={(evt) => addRef(evt.detail)}

plugins/tags-resources/src/components/TagsEditor.svelte

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
export let key: KeyedAttribute
4747
export let showTitle = true
4848
export let schema: '0' | '3' | '9' = key.attr.schema ?? '0'
49+
export let readonly = false
4950
5051
let elements: IdMap<TagElement> = new Map()
5152
const elementQuery = createQuery()
@@ -113,13 +114,15 @@
113114
<Label label={key.attr.label} />
114115
</span>
115116
<div class="buttons-group x-small">
116-
<Button
117-
icon={IconAdd}
118-
kind={'ghost'}
119-
showTooltip={{ label: tags.string.AddTagTooltip, props: { word: keyLabel } }}
120-
id={'add-tag'}
121-
on:click={addTag}
122-
/>
117+
{#if !readonly}
118+
<Button
119+
icon={IconAdd}
120+
kind={'ghost'}
121+
showTooltip={{ label: tags.string.AddTagTooltip, props: { word: keyLabel } }}
122+
id={'add-tag'}
123+
on:click={addTag}
124+
/>
125+
{/if}
123126
</div>
124127
</div>
125128
{/if}

plugins/tracker-resources/src/components/issues/timereport/ReportedTimeEditor.svelte

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,15 @@
106106
107107
&:not(.readonly) {
108108
cursor: pointer;
109-
}
110-
.add-action {
111-
visibility: hidden;
112-
}
113109
114-
&:hover {
115110
.add-action {
116-
visibility: visible;
111+
visibility: hidden;
112+
}
113+
114+
&:hover {
115+
.add-action {
116+
visibility: visible;
117+
}
117118
}
118119
}
119120
}

0 commit comments

Comments
 (0)