Skip to content

Commit

Permalink
fix file layout mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3orblade committed Feb 9, 2024
1 parent 2d463e2 commit a79888e
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/ts/component/menu/dataview/file/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,11 @@ const MenuDataviewFileList = observer(class MenuDataviewFileList extends React.C
};

load (clear: boolean, callBack?: (message: any) => void) {
const { config } = commonStore;
const { param } = this.props;
const { data } = param;
const { types, filter } = data;
const { filter } = data;
const filters: I.Filter[] = [
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: [ I.ObjectLayout.File, I.ObjectLayout.Image ] }
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: UtilObject.getFileLayouts() }
];
const sorts = [
{ relationKey: 'name', type: I.SortType.Asc },
Expand Down
12 changes: 7 additions & 5 deletions src/ts/component/menu/dataview/file/values.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ const MenuDataviewFileValues = observer(class MenuDataviewFileValues extends Rea
let content = null;

switch (item.layout) {
default:
case I.ObjectLayout.File: {
default: {
cn.push('isFile');
content = <File {...item} />;
break;
Expand Down Expand Up @@ -167,7 +166,7 @@ const MenuDataviewFileValues = observer(class MenuDataviewFileValues extends Rea
noClose: true,
placeholderFocus: translate('menuDataviewFileValuesFindAFile'),
filters: [
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: [ I.ObjectLayout.File, I.ObjectLayout.Image ] }
{ operator: I.FilterOperator.And, relationKey: 'layout', condition: I.FilterCondition.In, value: UtilObject.getFileLayouts() }
],
onChange: (value: string[], callBack?: () => void) => {
this.save(value);
Expand Down Expand Up @@ -248,14 +247,17 @@ const MenuDataviewFileValues = observer(class MenuDataviewFileValues extends Rea
case 'download': {
let url = '';
switch (item.layout) {
case I.ObjectLayout.File:
default: {
url = commonStore.fileUrl(item.id);
break;
};

case I.ObjectLayout.Image:
case I.ObjectLayout.Image: {
url = commonStore.imageUrl(item.id, Constant.size.image);
break;
};
};

if (url) {
Renderer.send('download', url);
};
Expand Down
18 changes: 10 additions & 8 deletions src/ts/component/util/iconObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ const IconObject = observer(class IconObject extends React.Component<Props> {
break;
};

case I.ObjectLayout.Bookmark: {
if (iconImage) {
icn = icn.concat([ 'iconCommon', 'c' + iconSize ]);
icon = <img src={commonStore.imageUrl(iconImage, iconSize * 2)} className={icn.join(' ')} />;
};
break;
};

case I.ObjectLayout.Image: {
if (id) {
cn.push('withImage');
Expand All @@ -251,14 +259,8 @@ const IconObject = observer(class IconObject extends React.Component<Props> {
break;
};

case I.ObjectLayout.Bookmark: {
if (iconImage) {
icn = icn.concat([ 'iconCommon', 'c' + iconSize ]);
icon = <img src={commonStore.imageUrl(iconImage, iconSize * 2)} className={icn.join(' ')} />;
};
break;
};

case I.ObjectLayout.Video:
case I.ObjectLayout.Audio:
case I.ObjectLayout.File: {
icn = icn.concat([ 'iconFile', 'c' + iconSize ]);
icon = <img src={UtilFile.iconImage(object)} className={icn.join(' ')} />;
Expand Down
10 changes: 6 additions & 4 deletions src/ts/lib/util/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class UtilData {
layoutClass (id: string, layout: I.ObjectLayout) {
let c = '';
switch (layout) {
default: c = UtilCommon.toCamelCase('is-' + I.ObjectLayout[layout]); break;
default: c = UtilCommon.toCamelCase(`is-${I.ObjectLayout[layout]}`); break;
case I.ObjectLayout.Image: c = (id ? 'isImage' : 'isFile'); break;
};
return c;
Expand Down Expand Up @@ -514,14 +514,16 @@ class UtilData {
};

case I.ObjectLayout.Human:
case I.ObjectLayout.Relation:
case I.ObjectLayout.File:
case I.ObjectLayout.Image: {
case I.ObjectLayout.Relation: {
ret.withIcon = true;
break;
};
};

if (UtilObject.isFileLayout(object.layout)) {
ret.withIcon = true;
};

if (checkType) {
ret.className.push('noSystemBlocks');
};
Expand Down
4 changes: 3 additions & 1 deletion src/ts/lib/util/graph.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { I, Relation, UtilCommon, UtilFile, UtilSmile } from 'Lib';
import { I, Relation, UtilCommon, UtilObject, UtilFile, UtilSmile } from 'Lib';
import { commonStore } from 'Store';
import Colors from 'json/colors.json';
import Theme from 'json/theme.json';
Expand All @@ -19,6 +19,8 @@ class UtilGraph {
break;
};

case I.ObjectLayout.Audio:
case I.ObjectLayout.Video:
case I.ObjectLayout.File: {
src = UtilFile.iconPath(d);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/ts/lib/util/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ class UtilMenu {
{ id: I.ObjectLayout.Task },
{ id: I.ObjectLayout.Set },
{ id: I.ObjectLayout.File },
{ id: I.ObjectLayout.Audio },
{ id: I.ObjectLayout.Video },
{ id: I.ObjectLayout.Image },
{ id: I.ObjectLayout.Type },
{ id: I.ObjectLayout.Relation },
Expand Down
12 changes: 8 additions & 4 deletions src/ts/lib/util/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,20 @@ class UtilObject {
actionByLayout (v: I.ObjectLayout): string {
v = v || I.ObjectLayout.Page;

if (this.isFileLayout(v)) {
return 'media';
};

if (this.isSetLayout(v)) {
return 'set';
};

let r = '';
switch (v) {
default: r = 'edit'; break;
case I.ObjectLayout.Date:
case I.ObjectLayout.Set:
case I.ObjectLayout.Collection: r = 'set'; break;
case I.ObjectLayout.Type: r = 'type'; break;
case I.ObjectLayout.Relation: r = 'relation'; break;
case I.ObjectLayout.File:
case I.ObjectLayout.Image: r = 'media'; break;
case I.ObjectLayout.Navigation: r = 'navigation'; break;
case I.ObjectLayout.Graph: r = 'graph'; break;
case I.ObjectLayout.Store: r = 'store'; break;
Expand Down
2 changes: 2 additions & 0 deletions src/ts/store/detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ class DetailStore {
};

case I.ObjectLayout.File:
case I.ObjectLayout.Audio:
case I.ObjectLayout.Video:
case I.ObjectLayout.Image: {
object = this.mapFile(object);
break;
Expand Down

0 comments on commit a79888e

Please sign in to comment.