Skip to content

Commit

Permalink
自动隐藏空字段? #1;添加展示字段设置功能,优化数据提取逻辑,更新版本号至v0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
loonghfut committed Dec 5, 2024
1 parent 923ff93 commit 4797041
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 128 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "siyuan-database-display",
"author": "steve",
"url": "https://github.com/loonghfut/siyuan-database-display",
"version": "0.1.4",
"version": "0.1.5",
"minAppVersion": "3.0.12",
"backends": [
"windows",
Expand Down
19 changes: 9 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { extractContents } from './handleKey';
import { SettingUtils } from "./libs/setting-utils";
import { addSettings } from './settings';

let disShow = null;
let isoutLog = true;
let currentDocId = null;
let currentDocId2 = null;
Expand Down Expand Up @@ -50,7 +51,12 @@ export default class DatabaseDisplay extends Plugin {
async showdata() {
//console.log("showdata2");
const viewKeys = await getAttributeViewKeys(currentDocId);
const contents1 = extractContents(viewKeys);
let contents1 = [];
if (disShow) {
contents1 = extractContents(viewKeys, disShow.split(','));
} else {
contents1 = extractContents(viewKeys);
}
console.log(contents1);
const contents = contents1.filter(element => element !== '' && element !== null && element !== undefined);
// 创建并设置新元素
Expand Down Expand Up @@ -120,15 +126,8 @@ export default class DatabaseDisplay extends Plugin {

onLayoutReady() {
this.settingUtils.load();
console.log(this.settingUtils.get("Check-mSelect"),'1');
console.log(this.settingUtils.get("Check-number"),'2');
console.log(this.settingUtils.get("Check-date"));
console.log(this.settingUtils.get("Check-text"));
console.log(this.settingUtils.get("Check-mAsset"));
console.log(this.settingUtils.get("Check-checkbox"));
console.log(this.settingUtils.get("Check-phone"));
console.log(this.settingUtils.get("Check-url"));
console.log(this.settingUtils.get("Check-email"),'9');
// console.log(this.settingUtils.get("dis-show"), '1');
disShow = this.settingUtils.get("dis-show");
// this.loadData(STORAGE_NAME);
}

Expand Down
124 changes: 7 additions & 117 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,126 +1,16 @@
// settings.ts
export function addSettings(settingUtils) {
settingUtils.addItem({
key: "",
value: true,
type: "checkbox",
title: "此设置暂时不可用,写到一半发现,这个设置选项多了的话好难看~~",
description: "此设置暂时不可用!此设置暂时不可用!此设置暂时不可用!",
key: "dis-show",
value: "",
type: "textarea",
title: "展示的字段(不填默认展示所有支持的字段)",
description: "输入展示的字段(mSelect,number,date,text,mAsset,checkbox,phone,url,email)",
action: {
// Called when focus is lost and content changes
callback: () => {

settingUtils.takeAndSave("dis-show");
}
}
});

settingUtils.addItem({
key: "Check-mSelect",
value: true,
type: "checkbox",
title: "多选和单选",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-mSelect");
}
}
});
settingUtils.addItem({
key: "Check-number",
value: true,
type: "checkbox",
title: "数字",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-number");
}
}
});
settingUtils.addItem({
key: "Check-date",
value: true,
type: "checkbox",
title: "日期",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-date");
}
}
});
settingUtils.addItem({
key: "Check-text",
value: true,
type: "checkbox",
title: "文本",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-text");
}
}
});
settingUtils.addItem({
key: "Check-mAsset",
value: true,
type: "checkbox",
title: "附件",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-mAsset");
}
}
});
settingUtils.addItem({
key: "Check-checkbox",
value: true,
type: "checkbox",
title: "多选框",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-checkbox");
}
}
});
settingUtils.addItem({
key: "Check-phone",
value: true,
type: "checkbox",
title: "电话",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-phone");
}
}
});
settingUtils.addItem({
key: "Check-url",
value: true,
type: "checkbox",
title: "链接",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-url");
}
}
});
settingUtils.addItem({
key: "Check-email",
value: true,
type: "checkbox",
title: "邮箱",
description: "选择是否显示",
action: {
callback: () => {
settingUtils.takeAndSave("Check-email");
}
}
});


}

0 comments on commit 4797041

Please sign in to comment.