+ node Index
This commit is contained in:
parent
3d001514ed
commit
b3859dd11b
2 changed files with 6 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/yaoapp/kun/any"
|
"github.com/yaoapp/kun/any"
|
||||||
"github.com/yaoapp/kun/exception"
|
"github.com/yaoapp/kun/exception"
|
||||||
"github.com/yaoapp/kun/maps"
|
"github.com/yaoapp/kun/maps"
|
||||||
|
"github.com/yaoapp/kun/str"
|
||||||
"github.com/yaoapp/xiang/config"
|
"github.com/yaoapp/xiang/config"
|
||||||
"github.com/yaoapp/xiang/helper"
|
"github.com/yaoapp/xiang/helper"
|
||||||
"github.com/yaoapp/xiang/share"
|
"github.com/yaoapp/xiang/share"
|
||||||
|
|
@ -169,8 +170,11 @@ func (workflow *WorkFlow) Setting(uid int, id interface{}) map[string]interface{
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes := workflow.FlowNodes(data.Dot())
|
nodes := workflow.FlowNodes(data.Dot())
|
||||||
|
_, idx := workflow.pickNode(string(str.Of(wflow["node_name"])))
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"nodes": nodes,
|
"nodes": nodes,
|
||||||
|
"node": nodes[idx],
|
||||||
|
"node_index": idx,
|
||||||
"read": true,
|
"read": true,
|
||||||
"write": any.Of(wflow["user_id"]).CInt() == uid,
|
"write": any.Of(wflow["user_id"]).CInt() == uid,
|
||||||
"actions": workflow.Actions,
|
"actions": workflow.Actions,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/yaoapp/kun/any"
|
"github.com/yaoapp/kun/any"
|
||||||
"github.com/yaoapp/kun/maps"
|
"github.com/yaoapp/kun/maps"
|
||||||
"github.com/yaoapp/kun/utils"
|
|
||||||
"github.com/yaoapp/xiang/config"
|
"github.com/yaoapp/xiang/config"
|
||||||
"github.com/yaoapp/xiang/flow"
|
"github.com/yaoapp/xiang/flow"
|
||||||
"github.com/yaoapp/xiang/model"
|
"github.com/yaoapp/xiang/model"
|
||||||
|
|
@ -70,8 +69,6 @@ func TestSaveUpdate(t *testing.T) {
|
||||||
Form: map[string]interface{}{"biz_id": 1, "name": "李明博"},
|
Form: map[string]interface{}{"biz_id": 1, "name": "李明博"},
|
||||||
})
|
})
|
||||||
|
|
||||||
utils.Dump(wflow)
|
|
||||||
|
|
||||||
data := maps.Of(wflow).Dot()
|
data := maps.Of(wflow).Dot()
|
||||||
assert.Equal(t, int64(1), data.Get("id"))
|
assert.Equal(t, int64(1), data.Get("id"))
|
||||||
assert.Equal(t, "assign", data.Get("name"))
|
assert.Equal(t, "assign", data.Get("name"))
|
||||||
|
|
@ -279,6 +276,7 @@ func TestSetting(t *testing.T) {
|
||||||
setting := assignFlow.Setting(1, 1)
|
setting := assignFlow.Setting(1, 1)
|
||||||
data := maps.Of(setting).Dot()
|
data := maps.Of(setting).Dot()
|
||||||
assert.Equal(t, true, data.Get("read"))
|
assert.Equal(t, true, data.Get("read"))
|
||||||
|
assert.Equal(t, "选择商务负责人", data.Get("node.label"))
|
||||||
assert.Equal(t, true, data.Get("write"))
|
assert.Equal(t, true, data.Get("write"))
|
||||||
|
|
||||||
id := any.Of(wflow["id"]).CInt()
|
id := any.Of(wflow["id"]).CInt()
|
||||||
|
|
@ -291,6 +289,7 @@ func TestSetting(t *testing.T) {
|
||||||
data = maps.Of(setting).Dot()
|
data = maps.Of(setting).Dot()
|
||||||
assert.Equal(t, true, data.Get("read"))
|
assert.Equal(t, true, data.Get("read"))
|
||||||
assert.Equal(t, false, data.Get("write"))
|
assert.Equal(t, false, data.Get("write"))
|
||||||
|
assert.Equal(t, "项目负责人审批", data.Get("node.label"))
|
||||||
assert.Equal(t, 2, data.Get("nodes.2.source"))
|
assert.Equal(t, 2, data.Get("nodes.2.source"))
|
||||||
assert.Equal(t, 2, data.Get("nodes.3.source"))
|
assert.Equal(t, 2, data.Get("nodes.3.source"))
|
||||||
assert.Equal(t, "assign", data.Get("name"))
|
assert.Equal(t, "assign", data.Get("name"))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue