mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 01:21:14 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
9df7deccd9
48
API.md
48
API.md
@ -52,6 +52,8 @@
|
||||
* [Notification](#Notification)
|
||||
* [Push message](#Push-message)
|
||||
* [Push error message](#Push-error-message)
|
||||
* [Network](#Network)
|
||||
* [Forward proxy](#Forward-proxy)
|
||||
* [System](#System)
|
||||
* [Get boot progress](#Get-boot-progress)
|
||||
* [Get system version](#Get-system-version)
|
||||
@ -1207,6 +1209,52 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
|
||||
```
|
||||
* `id`: Message ID
|
||||
|
||||
## Network
|
||||
|
||||
### Forward proxy
|
||||
|
||||
* `/api/network/forkProxy`
|
||||
* Parameters
|
||||
|
||||
```json
|
||||
{
|
||||
"url": "https://b3log.org/siyuan/",
|
||||
"method": "GET",
|
||||
"timeout": 7000,
|
||||
"contentType": "text/html",
|
||||
"headers": [
|
||||
{
|
||||
"Cookie": ""
|
||||
}
|
||||
],
|
||||
"payload": {}
|
||||
}
|
||||
```
|
||||
|
||||
* `url`: URL to forward
|
||||
* `method`: HTTP method, default is `POST`
|
||||
* `timeout`: timeout in milliseconds, default is `7000`
|
||||
* `contentType`: Content-Type, default is `application/json`
|
||||
* `headers`: HTTP headers
|
||||
* `payload`: HTTP payload, object or string
|
||||
* Return value
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"body": "",
|
||||
"contentType": "text/html",
|
||||
"elapsed": 1976,
|
||||
"headers": {
|
||||
},
|
||||
"status": 200,
|
||||
"url": "https://b3log.org/siyuan"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## System
|
||||
|
||||
### Get boot progress
|
||||
|
48
API_zh_CN.md
48
API_zh_CN.md
@ -52,6 +52,8 @@
|
||||
* [通知](#通知)
|
||||
* [推送消息](#推送消息)
|
||||
* [推送报错消息](#推送报错消息)
|
||||
* [网络](#网络)
|
||||
* [正向代理](#正向代理)
|
||||
* [系统](#系统)
|
||||
* [获取启动进度](#获取启动进度)
|
||||
* [获取系统版本](#获取系统版本)
|
||||
@ -1197,6 +1199,52 @@
|
||||
```
|
||||
* `id`:消息 ID
|
||||
|
||||
## 网络
|
||||
|
||||
### 正向代理
|
||||
|
||||
* `/api/network/forkProxy`
|
||||
* 参数
|
||||
|
||||
```json
|
||||
{
|
||||
"url": "https://b3log.org/siyuan/",
|
||||
"method": "GET",
|
||||
"timeout": 7000,
|
||||
"contentType": "text/html",
|
||||
"headers": [
|
||||
{
|
||||
"Cookie": ""
|
||||
}
|
||||
],
|
||||
"payload": {}
|
||||
}
|
||||
```
|
||||
|
||||
* `url`:转发的 URL
|
||||
* `method`:HTTP 方法,默认为 `GET`
|
||||
* `timeout`:超时时间,单位为毫秒,默认为 `7000` 毫秒
|
||||
* `contentType`:HTTP Content-Type,默认为 `application/json`
|
||||
* `headers`:HTTP 请求标头
|
||||
* `payload`:HTTP 请求体,对象或者是字符串
|
||||
* 返回值
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"body": "",
|
||||
"contentType": "text/html",
|
||||
"elapsed": 1976,
|
||||
"headers": {
|
||||
},
|
||||
"status": 200,
|
||||
"url": "https://b3log.org/siyuan"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 系统
|
||||
|
||||
### 获取启动进度
|
||||
|
@ -47,3 +47,4 @@ Below are the detailed changes in this version.
|
||||
* [Add text type column to Attribute View](https://github.com/siyuan-note/siyuan/issues/8693)
|
||||
* [Add select type column to Attribute View](https://github.com/siyuan-note/siyuan/issues/8694)
|
||||
* [Block data sync to Attribute View](https://github.com/siyuan-note/siyuan/issues/8696)
|
||||
* [Add kernel API `/api/network/forwardProxy`](https://github.com/siyuan-note/siyuan/issues/8724)
|
||||
|
@ -47,3 +47,4 @@
|
||||
* [屬性視圖添加文本類型列](https://github.com/siyuan-note/siyuan/issues/8693)
|
||||
* [屬性視圖添加選擇類型列](https://github.com/siyuan-note/siyuan/issues/8694)
|
||||
* [塊數據同步至屬性視圖](https://github.com/siyuan-note/siyuan/issues/8696)
|
||||
* [添加內核 API `/api/network/forwardProxy`](https://github.com/siyuan-note/siyuan/issues/8724)
|
||||
|
@ -47,3 +47,4 @@
|
||||
* [属性视图添加文本类型列](https://github.com/siyuan-note/siyuan/issues/8693)
|
||||
* [属性视图添加选择类型列](https://github.com/siyuan-note/siyuan/issues/8694)
|
||||
* [块数据同步至属性视图](https://github.com/siyuan-note/siyuan/issues/8696)
|
||||
* [添加内核 API `/api/network/forwardProxy`](https://github.com/siyuan-note/siyuan/issues/8724)
|
||||
|
@ -46,10 +46,12 @@ func forwardProxy(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
method := strings.ToUpper(arg["method"].(string))
|
||||
timeoutArg := arg["timeout"]
|
||||
method := "POST"
|
||||
if methodArg := arg["method"]; nil != methodArg {
|
||||
method = strings.ToUpper(methodArg.(string))
|
||||
}
|
||||
timeout := 7 * 1000
|
||||
if nil != timeoutArg {
|
||||
if timeoutArg := arg["timeout"]; nil != timeoutArg {
|
||||
timeout = int(timeoutArg.(float64))
|
||||
if 1 > timeout {
|
||||
timeout = 7 * 1000
|
||||
@ -66,14 +68,13 @@ func forwardProxy(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
contentType := arg["contentType"]
|
||||
if nil != contentType && "" != contentType {
|
||||
request.SetHeader("Content-Type", contentType.(string))
|
||||
contentType := "application/json"
|
||||
if contentTypeArg := arg["contentType"]; nil != contentTypeArg {
|
||||
contentType = contentTypeArg.(string)
|
||||
}
|
||||
request.SetHeader("Content-Type", contentType)
|
||||
|
||||
if "POST" == method {
|
||||
request.SetBody(arg["payload"])
|
||||
}
|
||||
request.SetBody(arg["payload"])
|
||||
|
||||
started := time.Now()
|
||||
resp, err := request.Send(method, destURL)
|
||||
|
115
kernel/av/av.go
115
kernel/av/av.go
@ -22,7 +22,6 @@ import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
@ -190,117 +189,3 @@ func RebuildAttributeViewTable(tx *sql.Tx, av *AttributeView) (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type AttributeViewSort struct {
|
||||
Column string `json:"column"` // 列 ID
|
||||
Order SortOrder `json:"order"` // 排序顺序
|
||||
}
|
||||
|
||||
type SortOrder string
|
||||
|
||||
const (
|
||||
SortOrderAsc SortOrder = "ASC"
|
||||
SortOrderDesc SortOrder = "DESC"
|
||||
)
|
||||
|
||||
func (av *AttributeView) SortRows() {
|
||||
if 1 > len(av.Sorts) {
|
||||
return
|
||||
}
|
||||
|
||||
type ColIndexSort struct {
|
||||
Index int
|
||||
Order SortOrder
|
||||
}
|
||||
|
||||
var colIndexSorts []*ColIndexSort
|
||||
for _, s := range av.Sorts {
|
||||
for i, c := range av.Columns {
|
||||
if c.ID == s.Column {
|
||||
colIndexSorts = append(colIndexSorts, &ColIndexSort{Index: i, Order: s.Order})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(av.Rows, func(i, j int) bool {
|
||||
for _, colIndexSort := range colIndexSorts {
|
||||
c := av.Columns[colIndexSort.Index]
|
||||
if c.Type == ColumnTypeBlock {
|
||||
continue
|
||||
}
|
||||
|
||||
result := av.Rows[i].Cells[colIndexSort.Index].Value.Compare(av.Rows[j].Cells[colIndexSort.Index].Value)
|
||||
if 0 == result {
|
||||
continue
|
||||
}
|
||||
|
||||
if colIndexSort.Order == SortOrderAsc {
|
||||
return 0 > result
|
||||
}
|
||||
return 0 < result
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
type AttributeViewFilter struct {
|
||||
Column string `json:"column"`
|
||||
Operator FilterOperator `json:"operator"`
|
||||
Value *Value `json:"value"`
|
||||
}
|
||||
|
||||
type FilterOperator string
|
||||
|
||||
const (
|
||||
FilterOperatorIsEqual FilterOperator = "="
|
||||
FilterOperatorIsNotEqual FilterOperator = "!="
|
||||
FilterOperatorIsGreater FilterOperator = ">"
|
||||
FilterOperatorIsGreaterOrEqual FilterOperator = ">="
|
||||
FilterOperatorIsLess FilterOperator = "<"
|
||||
FilterOperatorIsLessOrEqual FilterOperator = "<="
|
||||
FilterOperatorContains FilterOperator = "Contains"
|
||||
FilterOperatorDoesNotContain FilterOperator = "Does not contains"
|
||||
FilterOperatorIsEmpty FilterOperator = "Is empty"
|
||||
FilterOperatorIsNotEmpty FilterOperator = "Is not empty"
|
||||
FilterOperatorStartsWith FilterOperator = "Starts with"
|
||||
FilterOperatorEndsWith FilterOperator = "Ends with"
|
||||
FilterOperatorIsBetween FilterOperator = "Is between"
|
||||
FilterOperatorIsRelativeToToday FilterOperator = "Is relative to today"
|
||||
)
|
||||
|
||||
func (av *AttributeView) FilterRows() {
|
||||
if 1 > len(av.Filters) {
|
||||
return
|
||||
}
|
||||
|
||||
var colIndexes []int
|
||||
for _, f := range av.Filters {
|
||||
for i, c := range av.Columns {
|
||||
if c.ID == f.Column {
|
||||
colIndexes = append(colIndexes, i)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rows := []*Row{}
|
||||
for _, row := range av.Rows {
|
||||
pass := true
|
||||
for j, index := range colIndexes {
|
||||
c := av.Columns[index]
|
||||
if c.Type == ColumnTypeBlock {
|
||||
continue
|
||||
}
|
||||
|
||||
if !row.Cells[index].Value.CompareOperator(av.Filters[j].Value, av.Filters[j].Operator) {
|
||||
pass = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if pass {
|
||||
rows = append(rows, row)
|
||||
}
|
||||
}
|
||||
av.Rows = rows
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ type Value struct {
|
||||
Text *ValueText `json:"text,omitempty"`
|
||||
Number *ValueNumber `json:"number,omitempty"`
|
||||
Date *ValueDate `json:"date,omitempty"`
|
||||
Select *ValueSelect `json:"select,omitempty"`
|
||||
MSelect []*ValueSelect `json:"mSelect,omitempty"`
|
||||
}
|
||||
|
||||
@ -78,9 +77,7 @@ func (value *Value) Compare(other *Value) int {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
if nil != value.Select && nil != other.Select {
|
||||
return strings.Compare(value.Select.Content, other.Select.Content)
|
||||
}
|
||||
|
||||
if nil != value.MSelect && nil != other.MSelect {
|
||||
var v1 string
|
||||
for _, v := range value.MSelect {
|
||||
@ -172,21 +169,12 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool
|
||||
}
|
||||
}
|
||||
|
||||
if nil != value.Select && nil != other.Select {
|
||||
if nil != value.MSelect && nil != other.MSelect && 0 < len(value.MSelect) && 0 < len(other.MSelect) {
|
||||
switch operator {
|
||||
case FilterOperatorIsEqual:
|
||||
return value.Select.Content == other.Select.Content
|
||||
return value.MSelect[0].Content == other.MSelect[0].Content
|
||||
case FilterOperatorIsNotEqual:
|
||||
return value.Select.Content != other.Select.Content
|
||||
case FilterOperatorIsEmpty:
|
||||
return "" == strings.TrimSpace(value.Select.Content)
|
||||
case FilterOperatorIsNotEmpty:
|
||||
return "" != strings.TrimSpace(value.Select.Content)
|
||||
}
|
||||
}
|
||||
|
||||
if nil != value.MSelect && nil != other.MSelect {
|
||||
switch operator {
|
||||
return value.MSelect[0].Content != other.MSelect[0].Content
|
||||
case FilterOperatorContains:
|
||||
for _, v := range value.MSelect {
|
||||
if v.Content == other.MSelect[0].Content {
|
||||
|
@ -186,7 +186,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
|
||||
case CalcOperatorCountValues:
|
||||
countValues := 0
|
||||
for _, row := range av.Rows {
|
||||
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Select && "" != row.Cells[colIndex].Value.Select.Content {
|
||||
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.MSelect && 0 < len(row.Cells[colIndex].Value.MSelect) && nil != row.Cells[colIndex].Value.MSelect[0] && "" != row.Cells[colIndex].Value.MSelect[0].Content {
|
||||
countValues++
|
||||
}
|
||||
}
|
||||
@ -195,8 +195,8 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
|
||||
countUniqueValues := 0
|
||||
uniqueValues := map[string]bool{}
|
||||
for _, row := range av.Rows {
|
||||
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Select && "" != row.Cells[colIndex].Value.Select.Content {
|
||||
uniqueValues[row.Cells[colIndex].Value.Select.Content] = true
|
||||
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.MSelect && 0 < len(row.Cells[colIndex].Value.MSelect) && nil != row.Cells[colIndex].Value.MSelect[0] && "" != row.Cells[colIndex].Value.MSelect[0].Content {
|
||||
uniqueValues[row.Cells[colIndex].Value.MSelect[0].Content] = true
|
||||
countUniqueValues++
|
||||
}
|
||||
}
|
||||
@ -204,7 +204,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
|
||||
case CalcOperatorCountEmpty:
|
||||
countEmpty := 0
|
||||
for _, row := range av.Rows {
|
||||
if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.Select || "" == row.Cells[colIndex].Value.Select.Content {
|
||||
if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.MSelect || 1 > len(row.Cells[colIndex].Value.MSelect) || nil == row.Cells[colIndex].Value.MSelect[0] || "" == row.Cells[colIndex].Value.MSelect[0].Content {
|
||||
countEmpty++
|
||||
}
|
||||
}
|
||||
@ -212,7 +212,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
|
||||
case CalcOperatorCountNotEmpty:
|
||||
countNotEmpty := 0
|
||||
for _, row := range av.Rows {
|
||||
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Select && "" != row.Cells[colIndex].Value.Select.Content {
|
||||
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.MSelect && 0 < len(row.Cells[colIndex].Value.MSelect) && nil != row.Cells[colIndex].Value.MSelect[0] && "" != row.Cells[colIndex].Value.MSelect[0].Content {
|
||||
countNotEmpty++
|
||||
}
|
||||
}
|
||||
@ -220,7 +220,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
|
||||
case CalcOperatorPercentEmpty:
|
||||
countEmpty := 0
|
||||
for _, row := range av.Rows {
|
||||
if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.Select || "" == row.Cells[colIndex].Value.Select.Content {
|
||||
if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.MSelect || 1 > len(row.Cells[colIndex].Value.MSelect) || nil == row.Cells[colIndex].Value.MSelect[0] || "" == row.Cells[colIndex].Value.MSelect[0].Content {
|
||||
countEmpty++
|
||||
}
|
||||
}
|
||||
@ -228,7 +228,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
|
||||
case CalcOperatorPercentNotEmpty:
|
||||
countNotEmpty := 0
|
||||
for _, row := range av.Rows {
|
||||
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Select && "" != row.Cells[colIndex].Value.Select.Content {
|
||||
if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.MSelect && 0 < len(row.Cells[colIndex].Value.MSelect) && nil != row.Cells[colIndex].Value.MSelect[0] && "" != row.Cells[colIndex].Value.MSelect[0].Content {
|
||||
countNotEmpty++
|
||||
}
|
||||
}
|
||||
|
78
kernel/av/filter.go
Normal file
78
kernel/av/filter.go
Normal file
@ -0,0 +1,78 @@
|
||||
// SiYuan - Refactor your thinking
|
||||
// Copyright (c) 2020-present, b3log.org
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package av
|
||||
|
||||
type AttributeViewFilter struct {
|
||||
Column string `json:"column"`
|
||||
Operator FilterOperator `json:"operator"`
|
||||
Value *Value `json:"value"`
|
||||
}
|
||||
|
||||
type FilterOperator string
|
||||
|
||||
const (
|
||||
FilterOperatorIsEqual FilterOperator = "="
|
||||
FilterOperatorIsNotEqual FilterOperator = "!="
|
||||
FilterOperatorIsGreater FilterOperator = ">"
|
||||
FilterOperatorIsGreaterOrEqual FilterOperator = ">="
|
||||
FilterOperatorIsLess FilterOperator = "<"
|
||||
FilterOperatorIsLessOrEqual FilterOperator = "<="
|
||||
FilterOperatorContains FilterOperator = "Contains"
|
||||
FilterOperatorDoesNotContain FilterOperator = "Does not contains"
|
||||
FilterOperatorIsEmpty FilterOperator = "Is empty"
|
||||
FilterOperatorIsNotEmpty FilterOperator = "Is not empty"
|
||||
FilterOperatorStartsWith FilterOperator = "Starts with"
|
||||
FilterOperatorEndsWith FilterOperator = "Ends with"
|
||||
FilterOperatorIsBetween FilterOperator = "Is between"
|
||||
FilterOperatorIsRelativeToToday FilterOperator = "Is relative to today"
|
||||
)
|
||||
|
||||
func (av *AttributeView) FilterRows() {
|
||||
if 1 > len(av.Filters) {
|
||||
return
|
||||
}
|
||||
|
||||
var colIndexes []int
|
||||
for _, f := range av.Filters {
|
||||
for i, c := range av.Columns {
|
||||
if c.ID == f.Column {
|
||||
colIndexes = append(colIndexes, i)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rows := []*Row{}
|
||||
for _, row := range av.Rows {
|
||||
pass := true
|
||||
for j, index := range colIndexes {
|
||||
c := av.Columns[index]
|
||||
if c.Type == ColumnTypeBlock {
|
||||
continue
|
||||
}
|
||||
|
||||
if !row.Cells[index].Value.CompareOperator(av.Filters[j].Value, av.Filters[j].Operator) {
|
||||
pass = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if pass {
|
||||
rows = append(rows, row)
|
||||
}
|
||||
}
|
||||
av.Rows = rows
|
||||
}
|
72
kernel/av/sort.go
Normal file
72
kernel/av/sort.go
Normal file
@ -0,0 +1,72 @@
|
||||
// SiYuan - Refactor your thinking
|
||||
// Copyright (c) 2020-present, b3log.org
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package av
|
||||
|
||||
import "sort"
|
||||
|
||||
type AttributeViewSort struct {
|
||||
Column string `json:"column"` // 列 ID
|
||||
Order SortOrder `json:"order"` // 排序顺序
|
||||
}
|
||||
|
||||
type SortOrder string
|
||||
|
||||
const (
|
||||
SortOrderAsc SortOrder = "ASC"
|
||||
SortOrderDesc SortOrder = "DESC"
|
||||
)
|
||||
|
||||
func (av *AttributeView) SortRows() {
|
||||
if 1 > len(av.Sorts) {
|
||||
return
|
||||
}
|
||||
|
||||
type ColIndexSort struct {
|
||||
Index int
|
||||
Order SortOrder
|
||||
}
|
||||
|
||||
var colIndexSorts []*ColIndexSort
|
||||
for _, s := range av.Sorts {
|
||||
for i, c := range av.Columns {
|
||||
if c.ID == s.Column {
|
||||
colIndexSorts = append(colIndexSorts, &ColIndexSort{Index: i, Order: s.Order})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(av.Rows, func(i, j int) bool {
|
||||
for _, colIndexSort := range colIndexSorts {
|
||||
c := av.Columns[colIndexSort.Index]
|
||||
if c.Type == ColumnTypeBlock {
|
||||
continue
|
||||
}
|
||||
|
||||
result := av.Rows[i].Cells[colIndexSort.Index].Value.Compare(av.Rows[j].Cells[colIndexSort.Index].Value)
|
||||
if 0 == result {
|
||||
continue
|
||||
}
|
||||
|
||||
if colIndexSort.Order == SortOrderAsc {
|
||||
return 0 > result
|
||||
}
|
||||
return 0 < result
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
@ -364,10 +364,10 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if nil != cell.Value.Select {
|
||||
if oldName == cell.Value.Select.Content {
|
||||
cell.Value.Select.Content = newName
|
||||
cell.Value.Select.Color = newColor
|
||||
if nil != cell.Value.MSelect && 0 < len(cell.Value.MSelect) && nil != cell.Value.MSelect[0] {
|
||||
if oldName == cell.Value.MSelect[0].Content {
|
||||
cell.Value.MSelect[0].Content = newName
|
||||
cell.Value.MSelect[0].Color = newColor
|
||||
break
|
||||
}
|
||||
} else if nil != cell.Value.MSelect {
|
||||
@ -433,8 +433,8 @@ func removeAttributeViewColumnOption(operation *Operation) (err error) {
|
||||
}
|
||||
|
||||
if nil != cell.Value {
|
||||
if nil != cell.Value.Select {
|
||||
if optName == cell.Value.Select.Content {
|
||||
if nil != cell.Value.MSelect && 0 < len(cell.Value.MSelect) && nil != cell.Value.MSelect[0] {
|
||||
if optName == cell.Value.MSelect[0].Content {
|
||||
cell.Value = nil
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user