mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
31190aaa93
9 changed files with 79 additions and 9 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"buildIn": "Build-in",
|
"builtIn": "Built-in",
|
||||||
"endDate": "End date",
|
"endDate": "End date",
|
||||||
"needLogin": "This function needs to be logged in to use",
|
"needLogin": "This function needs to be logged in to use",
|
||||||
"calcResultCountAll": "COUNT",
|
"calcResultCountAll": "COUNT",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"buildIn": "Incorporado",
|
"builtIn": "Incorporado",
|
||||||
"endDate": "Fecha de finalización",
|
"endDate": "Fecha de finalización",
|
||||||
"needLogin": "Esta función requiere iniciar sesión en la cuenta antes de poder usarla",
|
"needLogin": "Esta función requiere iniciar sesión en la cuenta antes de poder usarla",
|
||||||
"calcResultCountAll": "CONTAR",
|
"calcResultCountAll": "CONTAR",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"buildIn": "Intégré",
|
"builtIn": "Intégré",
|
||||||
"endDate": "Date de fin",
|
"endDate": "Date de fin",
|
||||||
"needLogin": "La fonctionnalité nécessite un numéro de compte de connexion avant de pouvoir être utilisée",
|
"needLogin": "La fonctionnalité nécessite un numéro de compte de connexion avant de pouvoir être utilisée",
|
||||||
"calcResultCountAll": "COUNT",
|
"calcResultCountAll": "COUNT",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"buildIn": "內置",
|
"builtIn": "內置",
|
||||||
"endDate": "結束日期",
|
"endDate": "結束日期",
|
||||||
"needLogin": "該功能需要登錄賬號後才能使用",
|
"needLogin": "該功能需要登錄賬號後才能使用",
|
||||||
"calcResultCountAll": "行計數",
|
"calcResultCountAll": "行計數",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"buildIn": "内置",
|
"builtIn": "内置",
|
||||||
"endDate": "结束时间",
|
"endDate": "结束时间",
|
||||||
"needLogin": "该功能需要登录账号后才能使用",
|
"needLogin": "该功能需要登录账号后才能使用",
|
||||||
"calcResultCountAll": "行计数",
|
"calcResultCountAll": "行计数",
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import {confirmDialog} from "../dialog/confirmDialog";
|
||||||
import {getSearch, isMobile, isValidAttrName} from "../util/functions";
|
import {getSearch, isMobile, isValidAttrName} from "../util/functions";
|
||||||
import {isLocalPath, movePathTo, moveToPath, pathPosix} from "../util/pathName";
|
import {isLocalPath, movePathTo, moveToPath, pathPosix} from "../util/pathName";
|
||||||
import {MenuItem} from "./Menu";
|
import {MenuItem} from "./Menu";
|
||||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
|
||||||
import {saveExport} from "../protyle/export";
|
import {saveExport} from "../protyle/export";
|
||||||
import {openByMobile, writeText} from "../protyle/util/compatibility";
|
import {openByMobile, writeText} from "../protyle/util/compatibility";
|
||||||
import {fetchPost, fetchSyncPost} from "../util/fetch";
|
import {fetchPost, fetchSyncPost} from "../util/fetch";
|
||||||
|
|
@ -202,7 +201,7 @@ const genAttr = (attrs: IObject, focusName = "bookmark", cb: (dialog: Dialog, rm
|
||||||
<div class="layout-tab-bar fn__flex" style="flex-shrink:0;border-radius: var(--b3-border-radius-b) var(--b3-border-radius-b) 0 0">
|
<div class="layout-tab-bar fn__flex" style="flex-shrink:0;border-radius: var(--b3-border-radius-b) var(--b3-border-radius-b) 0 0">
|
||||||
<div class="item item--full item--focus" data-type="attr">
|
<div class="item item--full item--focus" data-type="attr">
|
||||||
<span class="fn__flex-1"></span>
|
<span class="fn__flex-1"></span>
|
||||||
<span class="item__text">${window.siyuan.languages.buildIn}</span>
|
<span class="item__text">${window.siyuan.languages.builtIn}</span>
|
||||||
<span class="fn__flex-1"></span>
|
<span class="fn__flex-1"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="item item--full${hasAV ? "" : " fn__none"}" data-type="av">
|
<div class="item item--full${hasAV ? "" : " fn__none"}" data-type="av">
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ const (
|
||||||
KeyTypeDate KeyType = "date"
|
KeyTypeDate KeyType = "date"
|
||||||
KeyTypeSelect KeyType = "select"
|
KeyTypeSelect KeyType = "select"
|
||||||
KeyTypeMSelect KeyType = "mSelect"
|
KeyTypeMSelect KeyType = "mSelect"
|
||||||
|
KeyTypeURL KeyType = "url"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Key 描述了属性视图属性列的基础结构。
|
// Key 描述了属性视图属性列的基础结构。
|
||||||
|
|
@ -97,6 +98,7 @@ type Value struct {
|
||||||
Number *ValueNumber `json:"number,omitempty"`
|
Number *ValueNumber `json:"number,omitempty"`
|
||||||
Date *ValueDate `json:"date,omitempty"`
|
Date *ValueDate `json:"date,omitempty"`
|
||||||
MSelect []*ValueSelect `json:"mSelect,omitempty"`
|
MSelect []*ValueSelect `json:"mSelect,omitempty"`
|
||||||
|
URL *ValueURL `json:"url,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (value *Value) ToJSONString() string {
|
func (value *Value) ToJSONString() string {
|
||||||
|
|
@ -222,6 +224,10 @@ type ValueSelect struct {
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ValueURL struct {
|
||||||
|
Content string `json:"content"`
|
||||||
|
}
|
||||||
|
|
||||||
// View 描述了视图的结构。
|
// View 描述了视图的结构。
|
||||||
type View struct {
|
type View struct {
|
||||||
ID string `json:"id"` // 视图 ID
|
ID string `json:"id"` // 视图 ID
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,8 @@ func (table *Table) CalcCols() {
|
||||||
table.calcColSelect(col, i)
|
table.calcColSelect(col, i)
|
||||||
case KeyTypeMSelect:
|
case KeyTypeMSelect:
|
||||||
table.calcColMSelect(col, i)
|
table.calcColMSelect(col, i)
|
||||||
|
case KeyTypeURL:
|
||||||
|
table.calcColURL(col, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -813,6 +815,69 @@ func (table *Table) calcColText(col *TableColumn, colIndex int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (table *Table) calcColURL(col *TableColumn, colIndex int) {
|
||||||
|
switch col.Calc.Operator {
|
||||||
|
case CalcOperatorCountAll:
|
||||||
|
col.Calc.Result = &Value{Number: NewFormattedValueNumber(float64(len(table.Rows)), NumberFormatNone)}
|
||||||
|
case CalcOperatorCountValues:
|
||||||
|
countValues := 0
|
||||||
|
for _, row := range table.Rows {
|
||||||
|
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.URL && "" != row.Cells[colIndex].Value.URL.Content {
|
||||||
|
countValues++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
col.Calc.Result = &Value{Number: NewFormattedValueNumber(float64(countValues), NumberFormatNone)}
|
||||||
|
case CalcOperatorCountUniqueValues:
|
||||||
|
countUniqueValues := 0
|
||||||
|
uniqueValues := map[string]bool{}
|
||||||
|
for _, row := range table.Rows {
|
||||||
|
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.URL && "" != row.Cells[colIndex].Value.URL.Content {
|
||||||
|
if !uniqueValues[row.Cells[colIndex].Value.URL.Content] {
|
||||||
|
uniqueValues[row.Cells[colIndex].Value.URL.Content] = true
|
||||||
|
countUniqueValues++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
col.Calc.Result = &Value{Number: NewFormattedValueNumber(float64(countUniqueValues), NumberFormatNone)}
|
||||||
|
case CalcOperatorCountEmpty:
|
||||||
|
countEmpty := 0
|
||||||
|
for _, row := range table.Rows {
|
||||||
|
if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.URL || "" == row.Cells[colIndex].Value.URL.Content {
|
||||||
|
countEmpty++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
col.Calc.Result = &Value{Number: NewFormattedValueNumber(float64(countEmpty), NumberFormatNone)}
|
||||||
|
case CalcOperatorCountNotEmpty:
|
||||||
|
countNotEmpty := 0
|
||||||
|
for _, row := range table.Rows {
|
||||||
|
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.URL && "" != row.Cells[colIndex].Value.URL.Content {
|
||||||
|
countNotEmpty++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
col.Calc.Result = &Value{Number: NewFormattedValueNumber(float64(countNotEmpty), NumberFormatNone)}
|
||||||
|
case CalcOperatorPercentEmpty:
|
||||||
|
countEmpty := 0
|
||||||
|
for _, row := range table.Rows {
|
||||||
|
if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.URL || "" == row.Cells[colIndex].Value.URL.Content {
|
||||||
|
countEmpty++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if 0 < len(table.Rows) {
|
||||||
|
col.Calc.Result = &Value{Number: NewFormattedValueNumber(float64(countEmpty)/float64(len(table.Rows)), NumberFormatPercent)}
|
||||||
|
}
|
||||||
|
case CalcOperatorPercentNotEmpty:
|
||||||
|
countNotEmpty := 0
|
||||||
|
for _, row := range table.Rows {
|
||||||
|
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.URL && "" != row.Cells[colIndex].Value.URL.Content {
|
||||||
|
countNotEmpty++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if 0 < len(table.Rows) {
|
||||||
|
col.Calc.Result = &Value{Number: NewFormattedValueNumber(float64(countNotEmpty)/float64(len(table.Rows)), NumberFormatPercent)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (table *Table) calcColBlock(col *TableColumn, colIndex int) {
|
func (table *Table) calcColBlock(col *TableColumn, colIndex int) {
|
||||||
switch col.Calc.Operator {
|
switch col.Calc.Operator {
|
||||||
case CalcOperatorCountAll:
|
case CalcOperatorCountAll:
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,7 @@ func addAttributeViewColumn(operation *Operation) (err error) {
|
||||||
|
|
||||||
keyType := av.KeyType(operation.Typ)
|
keyType := av.KeyType(operation.Typ)
|
||||||
switch keyType {
|
switch keyType {
|
||||||
case av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate, av.KeyTypeSelect, av.KeyTypeMSelect:
|
case av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate, av.KeyTypeSelect, av.KeyTypeMSelect, av.KeyTypeURL:
|
||||||
key := av.NewKey(operation.ID, operation.Name, keyType)
|
key := av.NewKey(operation.ID, operation.Name, keyType)
|
||||||
attrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: key})
|
attrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: key})
|
||||||
|
|
||||||
|
|
@ -741,7 +741,7 @@ func updateAttributeViewColumn(operation *Operation) (err error) {
|
||||||
|
|
||||||
colType := av.KeyType(operation.Typ)
|
colType := av.KeyType(operation.Typ)
|
||||||
switch colType {
|
switch colType {
|
||||||
case av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate, av.KeyTypeSelect, av.KeyTypeMSelect:
|
case av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate, av.KeyTypeSelect, av.KeyTypeMSelect, av.KeyTypeURL:
|
||||||
for _, keyValues := range attrView.KeyValues {
|
for _, keyValues := range attrView.KeyValues {
|
||||||
if keyValues.Key.ID == operation.ID {
|
if keyValues.Key.ID == operation.ID {
|
||||||
keyValues.Key.Name = operation.Name
|
keyValues.Key.Name = operation.Name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue