Исправлен вывод тегов

This commit is contained in:
Pavel Gnedov 2023-06-16 21:12:37 +07:00
parent 6e2d8c25f9
commit ad61df57b9
2 changed files with 27 additions and 19 deletions

View file

@ -37,11 +37,14 @@ export const KanbanCard = observer((props: Props) => {
} }
const timePassedClassName = `${KanbanCardCss.timepassedDot} ${timePassedColorClassName}`; const timePassedClassName = `${KanbanCardCss.timepassedDot} ${timePassedColorClassName}`;
let tagsSection = <></>; let tagsSection = <></>;
const tagsParams = props.store.params?.fields.find((field) => { const tagsParams = props.store.params.fields.find((field) => {
return field.component === 'tags'; return field.component === 'tags';
}); });
console.debug('Tag params:', tagsParams); // DEBUG
console.debug('Issue:', props.store.issue); // DEBUG
if (tagsParams && props.store.issue[tagsParams.path]) { if (tagsParams && props.store.issue[tagsParams.path]) {
const tags = props.store.issue[tagsParams.path] as TagProps[]; const tags = props.store.issue[tagsParams.path] as TagProps[];
console.debug(`Tags:`, tags); // DEBUG
tagsSection = ( tagsSection = (
<div> <div>
{tagsParams.label || 'Tags'}: {tags.map(tag => <KanbanCardTag tag={tag.tag} style={tag.style} />)} {tagsParams.label || 'Tags'}: {tags.map(tag => <KanbanCardTag tag={tag.tag} style={tag.style} />)}

View file

@ -14,9 +14,9 @@ export const ColumnStore = types.model({
return { return {
get cards(): ICardStore[] { get cards(): ICardStore[] {
return self.issues.map(issue => { return self.issues.map(issue => {
return { return CardStore.create({
issue: issue issue: issue
} as ICardStore; })
}); });
} }
} }
@ -77,24 +77,29 @@ export type CardField = {
export const CardSettings = types.model({}); export const CardSettings = types.model({});
export const CardStore = types.model({ export const CardParamsStore = types.optional(
issue: IssueStore, types.model({
params: types.maybe(types.model({ fields: types.array(
fields: types.optional( types.frozen<CardField>()
types.array(
types.frozen<CardField>()
),
[
{ component: 'text', label: 'Исп.', path: 'current_user.name' },
{ component: 'text', label: 'Прио.', path: 'priority.name' },
{ component: 'text', label: 'Версия', path: 'fixed_version.name' },
{ component: 'text', label: 'Прогресс', path: 'done_ratio' },
{ component: 'labor_costs' },
{ component: 'tags', label: 'Tags', path: 'styledTags' }
]
), ),
autoCollapse: types.boolean autoCollapse: types.boolean
})), }),
{
fields: [
{ component: 'text', label: 'Исп.', path: 'current_user.name' },
{ component: 'text', label: 'Прио.', path: 'priority.name' },
{ component: 'text', label: 'Версия', path: 'fixed_version.name' },
{ component: 'text', label: 'Прогресс', path: 'done_ratio' },
{ component: 'labor_costs' },
{ component: 'tags', label: 'Tags', path: 'styledTags' }
],
autoCollapse: false,
}
);
export const CardStore = types.model({
issue: IssueStore,
params: CardParamsStore
}); });
export interface ICardStore extends Instance<typeof CardStore> {} export interface ICardStore extends Instance<typeof CardStore> {}