mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
1fa16ccb86
3 changed files with 79 additions and 37 deletions
|
@ -559,7 +559,7 @@ func filterTextContent(operator FilterOperator, valueContent, otherValueContent
|
|||
func filterRelativeTime(valueMills int64, valueIsNotEmpty bool, operator FilterOperator, otherValueStart, otherValueEnd time.Time, direction RelativeDateDirection, otherValueStart2, otherValueEnd2 time.Time, direction2 RelativeDateDirection) bool {
|
||||
valueTime := time.UnixMilli(valueMills)
|
||||
|
||||
if otherValueStart.After(otherValueStart2) {
|
||||
if otherValueStart.After(otherValueStart2) && FilterOperatorIsBetween == operator {
|
||||
tmpStart, tmpEnd := otherValueStart2, otherValueEnd2
|
||||
otherValueStart2, otherValueEnd2 = otherValueStart, otherValueEnd
|
||||
otherValueStart, otherValueEnd = tmpStart, tmpEnd
|
||||
|
@ -657,7 +657,7 @@ func filterRelativeTime(valueMills int64, valueIsNotEmpty bool, operator FilterO
|
|||
func filterTime(valueMills int64, valueIsNotEmpty bool, otherValueMills, otherValueMills2 int64, operator FilterOperator) bool {
|
||||
valueTime := time.UnixMilli(valueMills)
|
||||
|
||||
if 0 != otherValueMills2 && otherValueMills > otherValueMills2 {
|
||||
if 0 != otherValueMills2 && otherValueMills > otherValueMills2 && FilterOperatorIsBetween == operator {
|
||||
tmp := otherValueMills2
|
||||
otherValueMills2 = otherValueMills
|
||||
otherValueMills = tmp
|
||||
|
@ -787,16 +787,11 @@ func (filter *ViewFilter) GetAffectValue(key *Key, addingBlockID string) (ret *V
|
|||
}
|
||||
|
||||
if nil == filter.Value {
|
||||
if nil != filter.RelativeDate {
|
||||
// 相对日期今天的动态日期不设置默认值
|
||||
return nil
|
||||
}
|
||||
// 两个值都空的情况下也不设置默认值
|
||||
return nil
|
||||
}
|
||||
|
||||
if FilterOperatorIsEmpty != filter.Operator && FilterOperatorIsNotEmpty != filter.Operator {
|
||||
if filter.Value.IsEmpty() {
|
||||
if filter.Value.IsEmpty() && nil == filter.RelativeDate {
|
||||
// 在不是过滤空值和非空值的情况下,空值不设置默认值 https://github.com/siyuan-note/siyuan/issues/11297
|
||||
return nil
|
||||
}
|
||||
|
@ -868,33 +863,55 @@ func (filter *ViewFilter) GetAffectValue(key *Key, addingBlockID string) (ret *V
|
|||
ret.Number = &ValueNumber{Content: 0, IsNotEmpty: true}
|
||||
}
|
||||
case KeyTypeDate:
|
||||
start := time.Now()
|
||||
end := start
|
||||
if nil != filter.Value.Date {
|
||||
start = time.UnixMilli(filter.Value.Date.Content)
|
||||
end = time.UnixMilli(filter.Value.Date.Content2)
|
||||
}
|
||||
if nil != filter.RelativeDate {
|
||||
start, end = calcRelativeTimeRegion(filter.RelativeDate.Count, filter.RelativeDate.Unit, filter.RelativeDate.Direction)
|
||||
}
|
||||
|
||||
switch filter.Operator {
|
||||
case FilterOperatorIsEqual:
|
||||
ret.Date = &ValueDate{Content: filter.Value.Date.Content, IsNotEmpty: true}
|
||||
case FilterOperatorIsNotEqual:
|
||||
ret.Date = &ValueDate{Content: util.CurrentTimeMillis(), IsNotEmpty: true}
|
||||
ret.Date = &ValueDate{Content: start.UnixMilli(), IsNotEmpty: true}
|
||||
case FilterOperatorIsGreater:
|
||||
ret.Date = &ValueDate{Content: filter.Value.Date.Content + 1000*60*60*24, IsNotEmpty: true}
|
||||
ret.Date = &ValueDate{Content: end.Add(24 * time.Hour).UnixMilli(), IsNotEmpty: true}
|
||||
case FilterOperatorIsGreaterOrEqual:
|
||||
ret.Date = &ValueDate{Content: filter.Value.Date.Content, IsNotEmpty: true}
|
||||
ret.Date = &ValueDate{Content: start.UnixMilli(), IsNotEmpty: true}
|
||||
case FilterOperatorIsLess:
|
||||
ret.Date = &ValueDate{Content: filter.Value.Date.Content - 1000*60*60*24, IsNotEmpty: true}
|
||||
ret.Date = &ValueDate{Content: start.Add(-24 * time.Hour).UnixMilli(), IsNotEmpty: true}
|
||||
case FilterOperatorIsLessOrEqual:
|
||||
ret.Date = &ValueDate{Content: filter.Value.Date.Content, IsNotEmpty: true}
|
||||
ret.Date = &ValueDate{Content: start.UnixMilli(), IsNotEmpty: true}
|
||||
case FilterOperatorIsBetween:
|
||||
start := filter.Value.Date.Content
|
||||
end := filter.Value.Date.Content2
|
||||
if start > end {
|
||||
tmp := end
|
||||
end = start
|
||||
start = tmp
|
||||
start2, end2 := start, end
|
||||
if nil != filter.RelativeDate2 {
|
||||
start2, end2 = calcRelativeTimeRegion(filter.RelativeDate2.Count, filter.RelativeDate2.Unit, filter.RelativeDate2.Direction)
|
||||
if start.After(start2) {
|
||||
tmp := start
|
||||
start = start2
|
||||
start2 = tmp
|
||||
}
|
||||
if end.Before(end2) {
|
||||
tmp := end
|
||||
end = end2
|
||||
end2 = tmp
|
||||
}
|
||||
} else {
|
||||
if start.After(end) {
|
||||
tmp := start
|
||||
start = end
|
||||
end = tmp
|
||||
}
|
||||
}
|
||||
now := util.CurrentTimeMillis()
|
||||
if start <= now && now <= end {
|
||||
ret.Date = &ValueDate{Content: now, IsNotEmpty: true}
|
||||
|
||||
now := time.Now()
|
||||
if start.Before(now) && now.Before(end) {
|
||||
ret.Date = &ValueDate{Content: now.UnixMilli(), IsNotEmpty: true}
|
||||
return
|
||||
}
|
||||
ret.Date = &ValueDate{Content: start, IsNotEmpty: true}
|
||||
ret.Date = &ValueDate{Content: start.UnixMilli(), IsNotEmpty: true}
|
||||
case FilterOperatorIsEmpty:
|
||||
ret.Date = &ValueDate{Content: 0, IsNotEmpty: false}
|
||||
case FilterOperatorIsNotEmpty:
|
||||
|
|
|
@ -242,9 +242,9 @@ func getAttrViewAddingBlockDefaultValues(attrView *av.AttributeView, view, group
|
|||
newValue.Email.Content = content
|
||||
case av.KeyTypePhone:
|
||||
newValue.Phone.Content = content
|
||||
case av.KeyTypeCheckbox:
|
||||
newValue.Checkbox.Checked = "" != content
|
||||
}
|
||||
} else if av.KeyTypeCheckbox == groupView.GroupVal.Type {
|
||||
newValue.Checkbox.Checked = groupView.GroupVal.Checkbox.Checked
|
||||
}
|
||||
|
||||
ret[groupKey.ID] = newValue
|
||||
|
@ -538,14 +538,19 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err error
|
|||
if view.Group.HideEmpty != oldHideEmpty {
|
||||
if !oldHideEmpty && view.Group.HideEmpty { // 启用隐藏空分组
|
||||
for _, g := range view.Groups {
|
||||
if g.GroupHidden == 0 && 1 > len(g.GroupItemIDs) {
|
||||
groupViewable := sql.RenderGroupView(attrView, view, g, "")
|
||||
// 必须经过渲染才能得到最终的条目数
|
||||
renderViewableInstance(groupViewable, view, attrView, 1, -1)
|
||||
if g.GroupHidden == 0 && 1 > groupViewable.(av.Collection).CountItems() {
|
||||
g.GroupHidden = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
if oldHideEmpty && !view.Group.HideEmpty { // 禁用隐藏空分组
|
||||
for _, g := range view.Groups {
|
||||
if g.GroupHidden == 1 && 1 > len(g.GroupItemIDs) {
|
||||
groupViewable := sql.RenderGroupView(attrView, view, g, "")
|
||||
renderViewableInstance(groupViewable, view, attrView, 1, -1)
|
||||
if g.GroupHidden == 1 && 1 > groupViewable.(av.Collection).CountItems() {
|
||||
g.GroupHidden = 0
|
||||
}
|
||||
}
|
||||
|
@ -557,9 +562,10 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err error
|
|||
// 首次设置分组时,如果分组字段是单选或多选类型,则将分组方式改为按选项排序 https://github.com/siyuan-note/siyuan/issues/15534
|
||||
view.Group.Order = av.GroupOrderSelectOption
|
||||
sortGroupsBySelectOption(view, groupKey)
|
||||
for i, g := range view.Groups {
|
||||
g.GroupSort = i
|
||||
}
|
||||
}
|
||||
|
||||
for i, g := range view.Groups {
|
||||
g.GroupSort = i
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1841,9 +1847,19 @@ func genAttrViewGroups(view *av.View, attrView *av.AttributeView) {
|
|||
}
|
||||
}
|
||||
|
||||
if 1 > len(groupItemsMap[groupValueDefault]) {
|
||||
// 始终保留默认分组 https://github.com/siyuan-note/siyuan/issues/15587
|
||||
groupItemsMap[groupValueDefault] = []av.Item{}
|
||||
if av.KeyTypeCheckbox != groupKey.Type {
|
||||
if 1 > len(groupItemsMap[groupValueDefault]) {
|
||||
// 始终保留默认分组 https://github.com/siyuan-note/siyuan/issues/15587
|
||||
groupItemsMap[groupValueDefault] = []av.Item{}
|
||||
}
|
||||
} else {
|
||||
// 对于复选框分组,空白分组表示未选中状态,始终保留 https://github.com/siyuan-note/siyuan/issues/15650
|
||||
if nil == groupItemsMap[""] {
|
||||
groupItemsMap[""] = []av.Item{}
|
||||
}
|
||||
if nil == groupItemsMap["√"] {
|
||||
groupItemsMap["√"] = []av.Item{}
|
||||
}
|
||||
}
|
||||
|
||||
for groupValue, groupItems := range groupItemsMap {
|
||||
|
@ -1885,6 +1901,13 @@ func genAttrViewGroups(view *av.View, attrView *av.AttributeView) {
|
|||
v.GroupVal.Relation.Contents = []*av.Value{destBlock}
|
||||
}
|
||||
}
|
||||
} else if av.KeyTypeCheckbox == groupKey.Type {
|
||||
v.GroupVal.Text = nil
|
||||
v.GroupVal.Type = av.KeyTypeCheckbox
|
||||
v.GroupVal.Checkbox = &av.ValueCheckbox{}
|
||||
if "" != groupValue {
|
||||
v.GroupVal.Checkbox.Checked = true
|
||||
}
|
||||
}
|
||||
v.GroupSort = -1
|
||||
view.Groups = append(view.Groups, v)
|
||||
|
|
|
@ -184,14 +184,16 @@ func hideEmptyGroupViews(view *av.View, viewable av.Viewable) {
|
|||
return
|
||||
}
|
||||
|
||||
groupHidden := viewable.GetGroupHidden()
|
||||
if !view.Group.HideEmpty {
|
||||
if 2 != viewable.GetGroupHidden() {
|
||||
if 2 != groupHidden {
|
||||
viewable.SetGroupHidden(0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if 1 == viewable.GetGroupHidden() && 0 < viewable.(av.Collection).CountItems() {
|
||||
itemCount := viewable.(av.Collection).CountItems()
|
||||
if 1 == groupHidden && 0 < itemCount {
|
||||
viewable.SetGroupHidden(0)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue