Skip to content

Commit bd9c156

Browse files
committed
feat: add logoUrl editing option to collections
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent b2164b4 commit bd9c156

4 files changed

Lines changed: 35 additions & 3 deletions

File tree

frontend/src/modules/admin/modules/collections/components/lf-collection-add.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@
5656
</lf-field>
5757
</article>
5858

59+
<!-- Logo URL -->
60+
<article class="mb-6">
61+
<lf-field label-text="Logo URL">
62+
<lf-input
63+
v-model="form.logoUrl"
64+
class="h-10"
65+
placeholder="https://example.com/logo.png"
66+
:invalid="$v.logoUrl.$invalid && $v.logoUrl.$dirty"
67+
@blur="$v.logoUrl.$touch()"
68+
@change="$v.logoUrl.$touch()"
69+
/>
70+
<lf-field-messages
71+
:validation="$v.logoUrl"
72+
:error-messages="{ url: 'Please enter a valid URL' }"
73+
/>
74+
</lf-field>
75+
</article>
76+
5977
<!-- Category -->
6078
<article class="mb-5">
6179
<lf-field label-text="Category">
@@ -142,7 +160,7 @@
142160
<script setup lang="ts">
143161
import formChangeDetector from '@/shared/form/form-change';
144162
import useVuelidate from '@vuelidate/core';
145-
import { required, maxLength } from '@vuelidate/validators';
163+
import { required, maxLength, url } from '@vuelidate/validators';
146164
import {
147165
computed, onMounted, reactive, ref, watch,
148166
} from 'vue';
@@ -185,6 +203,7 @@ const form = reactive<CollectionFormModel>({
185203
description: '',
186204
type: '',
187205
categoryId: null,
206+
logoUrl: '',
188207
projects: [],
189208
starred: false,
190209
});
@@ -195,6 +214,7 @@ const rules = {
195214
maxLength,
196215
},
197216
description: { required: (value: string) => value.trim().length },
217+
logoUrl: { url },
198218
projects: { required: (value: any) => value.length > 0 },
199219
};
200220
@@ -218,6 +238,7 @@ const fillForm = (record?: CollectionModel) => {
218238
Object.assign(form, record);
219239
form.type = record.category?.categoryGroupType;
220240
form.categoryId = record.categoryId || null;
241+
form.logoUrl = record.logoUrl || '';
221242
}
222243
223244
formSnapshot();
@@ -241,6 +262,7 @@ const onSubmit = () => {
241262
const request: CollectionRequest = {
242263
name: form.name,
243264
description: form.description,
265+
logoUrl: form.logoUrl || undefined,
244266
projects: form.projects.map((project: any) => ({
245267
id: project.id,
246268
starred: project?.starred || false,

frontend/src/modules/admin/modules/collections/components/lf-collection-table.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
<lf-icon name="rectangle-history" :size="16" class="text-gray-400 mr-2" />
2222
{{ collection.name }}
2323
<lf-icon v-if="collection.starred" name="star" type="solid" :size="16" class="text-yellow-300 ml-2" />
24+
<span
25+
v-if="collection.ssoUserId"
26+
class="ml-2 px-2 py-0.5 text-xs font-medium rounded-full bg-primary-100 text-primary-700"
27+
>
28+
Community
29+
</span>
2430
</div>
2531
</lf-table-cell>
2632

frontend/src/modules/admin/modules/collections/models/collection.model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export interface CollectionModel {
77
description: string;
88
slug: string;
99
categoryId?: string;
10+
logoUrl?: string;
11+
ssoUserId?: string;
1012
projects: InsightsProjectModel[];
1113
category: Category & {categoryGroupType: string, categoryGroupName: string};
1214
starred?: boolean;
@@ -16,6 +18,7 @@ export interface CollectionRequest {
1618
name: string;
1719
description: string;
1820
categoryId: string | null;
21+
logoUrl?: string;
1922
slug: string;
2023
starred: boolean;
2124
projects: {
@@ -28,6 +31,7 @@ export interface CollectionFormModel {
2831
description: string;
2932
type: string | null;
3033
categoryId: string | null;
34+
logoUrl: string;
3135
projects: InsightsProjectModel[];
3236
starred: boolean;
3337
}

services/libs/data-access-layer/src/collections/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ export async function createCollection(
136136
): Promise<ICollection> {
137137
return qx.selectOne(
138138
`
139-
INSERT INTO collections (name, description, slug, "categoryId", starred)
140-
VALUES ($(name), $(description), $(slug), $(categoryId), $(starred))
139+
INSERT INTO collections (name, description, slug, "categoryId", starred, "logoUrl")
140+
VALUES ($(name), $(description), $(slug), $(categoryId), $(starred), $(logoUrl))
141141
RETURNING *
142142
`,
143143
collection,

0 commit comments

Comments
 (0)