Открыть боковую панель
valov_1205
universo-phaser
Коммиты
9c9f4c73
Коммит
9c9f4c73
создал
Ноя 14, 2023
по автору
avathar
Просмотр файлов
#102 продолжен рефакторинг
#112 базовая кнопка создана удален файл mock.ts
владелец
6db43c8e
Изменения
11
Скрыть пробелы
Построчно
Рядом
universo-frontend/src/apps/cards/CreateItemsBox.ts
Просмотр файла @
9c9f4c73
...
...
@@ -43,9 +43,9 @@ const CreateItemsBox = (scene: SceneType, cards: TreeNode, registry): Sizer => {
});
itemsBox
.
addBackground
(
scene
.
rexUI
.
add
.
roundRectangle
({}),
'
background
'
);
if
(
cards
.
getC
hildrens
()
.
length
)
{
for
(
let
i
=
0
;
i
<
cards
.
getC
hildrens
()
.
length
;
i
++
)
{
itemsBox
.
add
(
CreateItem
(
scene
,
cards
.
getC
hildrens
()
[
i
].
getN
ame
()
),
{
if
(
cards
.
c
hildrens
.
length
)
{
for
(
let
i
=
0
;
i
<
cards
.
c
hildrens
.
length
;
i
++
)
{
itemsBox
.
add
(
CreateItem
(
scene
,
cards
.
c
hildrens
[
i
].
n
ame
),
{
proportion
:
0
,
expand
:
true
,
});
...
...
universo-frontend/src/apps/kanbans/CreateColumnPanel.ts
Просмотр файла @
9c9f4c73
...
...
@@ -31,7 +31,7 @@ const CreateColumnPanel = (scene: SceneType, cards: TreeNode, registry) => {
background
:
scene
.
rexUI
.
add
.
roundRectangle
({
strokeColor
:
COLOR_DARK
,
}),
title
:
CreateTitle
(
scene
,
cards
.
getN
ame
()
,
registry
),
title
:
CreateTitle
(
scene
,
cards
.
n
ame
,
registry
),
content
:
CreateItemsBox
(
scene
,
cards
,
registry
),
proportion
:
{
content
:
1
,
...
...
universo-frontend/src/apps/kanbans/CreateColumnPanelsBox.ts
Просмотр файла @
9c9f4c73
...
...
@@ -51,7 +51,7 @@ const CreateColumnPanelsBox = (
// 'background'
// )
item
.
getC
hildrens
()
.
forEach
((
child
)
=>
{
item
.
c
hildrens
.
forEach
((
child
)
=>
{
const
columnPanel
=
CreateColumnPanel
(
scene
,
child
,
registry
);
columnPanelsBox
.
add
(
columnPanel
,
{
proportion
:
0
,
expand
:
true
});
});
...
...
universo-frontend/src/apps/kanbans/CreateHeader.ts
Просмотр файла @
9c9f4c73
...
...
@@ -16,11 +16,11 @@ const CreateHeader = function (
})
.
addBackground
(
scene
.
rexUI
.
add
.
roundRectangle
(
0
,
0
,
20
,
20
,
0
,
COLOR_DARK
));
const
headerLabel
=
scene
.
rexUI
.
add
.
label
({
text
:
scene
.
add
.
text
(
0
,
0
,
objekto
.
getN
ame
()
),
text
:
scene
.
add
.
text
(
0
,
0
,
objekto
.
n
ame
),
});
registry
.
events
.
on
(
'
changedata
'
,
(
parent
,
key
,
data
,
previousData
)
=>
{
if
(
data
.
getU
uid
()
===
objekto
.
getU
uid
()
)
{
headerLabel
.
setText
(
data
.
getN
ame
()
);
if
(
data
.
u
uid
===
objekto
.
u
uid
)
{
headerLabel
.
setText
(
data
.
n
ame
);
}
});
const
dropDownButton
=
CreateDropDownList
(
scene
);
...
...
universo-frontend/src/apps/kanbans/CreateScrollablePanel.ts
Просмотр файла @
9c9f4c73
...
...
@@ -47,7 +47,7 @@ const CreateScrollablePanel = (
panel
:
{
child
:
CreateColumnPanelsBox
(
scene
,
objectTree
?
objectTree
[
0
]?.
getC
hildrens
()
[
0
]
:
{},
objectTree
?
objectTree
[
0
]?.
c
hildrens
[
0
]
:
{},
registry
,
),
mask
:
{
...
...
universo-frontend/src/apps/kanbans/mock.ts
удалено
100644 → 0
Просмотр файла @
6db43c8e
import
{
KanvasoObjekto
,
KanvasojKanvasoObjekto
,
Edge
,
}
from
'
./../../types/stores/kanvaso.d
'
;
//@ts-nocheck
export
const
a
=
{
Boards
:
[
{
id
:
1
,
BoardName
:
'
HeaderBoard
'
,
},
],
Columns
:
[
{
id
:
1
,
ColumnName
:
'
HeaderColumn
'
,
},
],
};
export
{
a
as
kanvaso
}
from
'
./kanvaso.js
'
;
import
{
a
as
objekto
}
from
'
./objekto.js
'
;
import
{
TreeNode
}
from
'
./../../types/stores/kanvaso.d
'
;
function
convertToTree
(
flatArray
:
TreeNode
[]):
TreeNode
[]
{
let
arr
=
objekto
.
data
.
kanvasojKanvasoObjekto
.
edges
;
//@ts-ignore
arr
=
arr
.
map
((
item
)
=>
item
.
node
);
// Создаем копию исходного массива, чтобы не изменять его. Глубокая копия, так как в некоторых браузерах проблемы с добавлением children
const
nodes
=
JSON
.
parse
(
JSON
.
stringify
(
arr
));
// const nodes = copy(arr);
// Создаем объект для быстрого доступа к каждому узлу по его UUID.
const
nodeMap
:
Record
<
string
,
TreeNode
>
=
{};
// Инициализируем nodeMap и добавляем каждому узлу пустой массив children.
nodes
.
forEach
((
node
)
=>
{
node
.
children
=
[];
nodeMap
[
node
.
uuid
]
=
node
;
});
// Фильтруем узлы, чтобы сохранить только корневые узлы в результирующем массиве.
const
tree
:
TreeNode
[]
=
nodes
.
filter
((
node
)
=>
{
// Если у узла есть posedantoUuid, добавляем его в children его родителя.
if
(
node
.
kanvasojKanvasoobjektoligiloLigilo
)
{
const
parent
=
nodeMap
[
node
.
kanvasojKanvasoobjektoligiloLigilo
.
posedanto
.
uuid
];
if
(
parent
)
{
parent
.
children
!
.
push
(
node
);
}
// Узел не является корневым, поэтому исключаем его из результирующего массива.
return
false
;
}
// Узел является корневым.
return
true
;
});
return
tree
;
}
//@ts-ignore
const
result
=
convertToTree
(
objekto
);
export
{
result
as
objekto
};
universo-frontend/src/apps/spaces-2d/Spaces2D.vue
Просмотр файла @
9c9f4c73
...
...
@@ -26,25 +26,26 @@ import 'phaser';
import
CreateScrollablePanel
from
'
../kanbans/CreateScrollablePanel
'
;
import
{
useKanvasoStore
}
from
'
src/stores/kanvaso
'
;
import
{
mapActions
,
mapState
}
from
'
pinia
'
;
// import { objekto } from './mock';
// import PreloadScene from './PreloadScene';
// import BootScene from './BootScene';
import
{
KanvasojKanvaso
,
TreeNode
}
from
'
src/types/stores/kanvaso
'
;
import
{
watch
,
computed
}
from
'
vue
'
;
import
{
Router
,
useRouter
}
from
'
vue-router
'
;
//
declare const window: {
// objekto: TreeNode
;
//
} & Window;
declare
const
window
:
{
router
:
Router
;
}
&
Window
;
class
EndlessCanvas
extends
Phaser
.
Scene
{
[
x
:
string
]:
any
;
rexUI
:
any
;
constructor
()
{
super
({
key
:
'
endless-canvas
'
,
});
//@ts-ignore
this
.
store
=
useKanvasoStore
();
this
.
router
=
window
.
router
;
}
preload
()
{
...
...
@@ -56,21 +57,17 @@ class EndlessCanvas extends Phaser.Scene {
);
this
.
load
.
image
(
'
icon
'
,
'
phaser/stretching_icon.png
'
);
//заполняем registry объектами холста
//@ts-ignore
this
.
store
.
getMap
.
forEach
((
element
)
=>
{
this
.
registry
.
set
(
element
.
getU
uid
()
,
element
);
this
.
registry
.
set
(
element
.
u
uid
,
element
);
});
console
.
log
(
'
this.registry :>>
'
,
this
.
registry
);
//организуем слежение за getMap и в случае его изменения выясняем что изменилось и обновляем данные в registry
//@ts-ignore
// console.log('this.store.getMap :>> ', this.store.getMap);
//@ts-ignore
const
map
=
computed
(()
=>
this
.
store
.
getMap
);
watch
(
map
,
(
newData
,
oldData
)
=>
{
newData
.
forEach
((
element
)
=>
{
const
uuid
=
element
.
getU
uid
()
;
const
oldElement
=
oldData
.
filter
((
el
)
=>
el
.
getU
uid
()
===
uuid
)[
0
];
const
uuid
=
element
.
u
uid
;
const
oldElement
=
oldData
.
filter
((
el
)
=>
el
.
u
uid
===
uuid
)[
0
];
if
(
JSON
.
stringify
(
element
)
!==
JSON
.
stringify
(
oldElement
))
{
this
.
registry
.
set
(
uuid
,
element
);
}
...
...
@@ -79,14 +76,14 @@ class EndlessCanvas extends Phaser.Scene {
// Некоторые идеи к обдумыванию:
// Добавляем обработку добавления новых элементов
newData
.
forEach
((
element
)
=>
{
if
(
!
oldData
.
some
((
el
)
=>
el
.
getU
uid
()
===
element
.
getU
uid
()
))
{
this
.
registry
.
set
(
element
.
getU
uid
()
,
element
);
if
(
!
oldData
.
some
((
el
)
=>
el
.
u
uid
===
element
.
u
uid
))
{
this
.
registry
.
set
(
element
.
u
uid
,
element
);
}
});
// Добавляем обработку удаления элементов
oldData
.
forEach
((
element
)
=>
{
if
(
!
newData
.
some
((
el
)
=>
el
.
getU
uid
()
===
element
.
getU
uid
()
))
{
this
.
registry
.
remove
(
element
.
getU
uid
()
);
if
(
!
newData
.
some
((
el
)
=>
el
.
u
uid
===
element
.
u
uid
))
{
this
.
registry
.
remove
(
element
.
u
uid
);
}
});
//Как обновлять реестр понятно. Не совсем понятно пока как убирать добавлять внутриигровые объекты
...
...
@@ -94,15 +91,22 @@ class EndlessCanvas extends Phaser.Scene {
}
create
():
void
{
const
back
=
this
.
add
.
text
(
0
,
0
,
'
<<
'
,
{
fontSize
:
'
24px
'
,
backgroundColor
:
'
#000
'
,
color
:
'
#fff
'
,
});
back
.
setInteractive
();
back
.
on
(
'
pointerdown
'
,
()
=>
{
this
.
router
.
push
(
'
/projects
'
);
});
this
.
cameras
.
main
.
setBackgroundColor
(
'
#abcdef
'
);
// Скрываем экран загрузки здесь, потому что на этом этапе preload уже завершен
document
.
getElementById
(
'
loading-screen
'
).
style
.
display
=
'
none
'
;
//@ts-ignore
const
topPanel
=
CreateScrollablePanel
(
this
,
//@ts-ignore
this
.
store
.
getTree
,
this
.
registry
,
)
...
...
@@ -137,17 +141,15 @@ const config: Phaser.Types.Core.GameConfig = {
};
export
default
{
name
:
'
YourComponentName
'
,
name
:
'
EndlessCanvas
'
,
data
()
{
return
{
wsSubscribe
:
null
,
};
},
computed
:
{
...
mapState
(
useKanvasoStore
,
[
'
getTree
'
]),
...
mapState
(
useKanvasoStore
,
{
project
:
'
getKanvaso
'
,
kanvasoTree
:
'
getTree
'
,
}),
// ...mapState(useCurrentUserStore, { userId: 'getUserId' }),
...
...
@@ -158,11 +160,7 @@ export default {
return
this
.
$route
?.
params
?.
uuid
||
''
;
},
},
// watch: {
// getTree(val) {
// window.objekto = val;
// },
// },
methods
:
{
...
mapActions
(
useKanvasoStore
,
[
'
onGetKanvasoFull
'
,
...
...
@@ -203,6 +201,7 @@ export default {
};
window
.
addEventListener
(
'
resize
'
,
resizeHandler
);
window
.
router
=
this
.
$router
;
const
game
=
new
Phaser
.
Game
(
config
);
// window.addEventListener('resize', function (event) {
...
...
@@ -225,6 +224,8 @@ export default {
},
beforeUnmount
()
{
this
.
wsSubscribe
.
unsubscribe
();
document
.
getElementsByTagName
(
'
body
'
)[
0
].
style
.
overflow
=
'
auto
'
;
// delete window.objekto;
},
};
...
...
universo-frontend/src/components/TreeNode.vue
Просмотр файла @
9c9f4c73
...
...
@@ -5,11 +5,11 @@
<div>
<div>
<!--
{{
node
.
nomo
.
enhavo
}}
-->
{{
node
.
getN
ame
()
}}
<span
class=
"text-green"
>
{{
node
.
getC
hildrens
()
.
length
}}
</span>
{{
node
.
n
ame
}}
<span
class=
"text-green"
>
{{
node
.
c
hildrens
.
length
}}
</span>
<span
v-if=
"isAdmin"
>
<q-icon
v-if=
"node.isPublished
()
"
v-if=
"node.isPublished"
color=
"blue"
name=
"published_with_changes"
/>
...
...
@@ -18,7 +18,7 @@
<span
v-if=
"isAdmin"
>
<q-icon
v-if=
"node.isDeleted
()
"
v-if=
"node.isDeleted"
color=
"orange"
name=
"delete_forever"
/>
...
...
@@ -26,14 +26,14 @@
</span>
</div>
<div
class=
"text-subtitle1"
>
{{
node
.
getD
escription
()
}}
{{
node
.
d
escription
}}
</div>
<div
class=
"text-subtitle2 text-brown"
>
{{
node
.
getU
uid
()
}}
{{
node
.
u
uid
}}
</div>
<div
class=
"text-subtitle2 text-green"
>
{{
node
.
getT
ype
()
}}
{{
node
.
t
ype
}}
</div>
</div>
<!--
<pre
class=
"text-caption text-brown"
>
{{
node
}}
</pre>
-->
...
...
@@ -48,7 +48,7 @@
<q-tooltip>
Редактирование
</q-tooltip>
</q-btn>
<q-btn
v-if=
"node.
getT
ypeId
()
<
4"
v-if=
"node.
t
ypeId
<
4"
flat
round
color=
"teal"
...
...
@@ -71,10 +71,10 @@
<!-- Рекурсивно отображаем дочерние узлы -->
<q-card-section
v-if=
"node && node.
getC
hildrens
()
.length"
v-if=
"node && node.
c
hildrens.length"
class=
"q-pa-md row items-start q-gutter-md"
>
<template
v-for=
"child in node.
getC
hildrens
()
"
:key=
"child.
getU
uid
()
"
>
<template
v-for=
"child in node.
c
hildrens"
:key=
"child.
u
uid"
>
<tree-node
:node=
"child"
@
edit=
"$emit('edit', $event)"
...
...
universo-frontend/src/pages/CurrentProjectPage.vue
Просмотр файла @
9c9f4c73
...
...
@@ -29,7 +29,7 @@
flat
bordered
v-for=
"rootNode in kanvasoTree"
:key=
"rootNode.
getU
uid
()
"
:key=
"rootNode.
u
uid"
class=
"flex row"
>
<tree-node
...
...
@@ -187,15 +187,15 @@ export default defineComponent({
this
.
dialogMessage
=
'
Редактирование элемента
'
;
this
.
nameLabel
=
'
Название
'
;
this
.
descriptionLabel
=
'
Описание
'
;
this
.
name
=
this
.
oldName
=
node
.
getN
ame
()
;
this
.
description
=
this
.
oldDescription
=
node
.
getD
escription
()
;
this
.
name
=
this
.
oldName
=
node
.
n
ame
;
this
.
description
=
this
.
oldDescription
=
node
.
d
escription
;
this
.
payload
=
{
nomo
:
this
.
name
,
priskribo
:
this
.
description
,
kanvasoUuid
:
this
.
projectUuid
,
// posedantoUzantoId: this.userId,
uuid
:
node
.
getU
uid
()
,
uuid
:
node
.
u
uid
,
};
this
.
dialogMethod
=
this
.
updateKanvasoObjekto
;
this
.
addOrEditDialog
=
true
;
...
...
@@ -223,7 +223,7 @@ export default defineComponent({
priskribo
:
this
.
description
,
kanvasoUuid
:
this
.
projectUuid
,
posedantoUzantoId
:
this
.
userId
,
tipoId
:
node
.
getT
ypeId
()
<
4
?
node
.
getT
ypeId
()
+
1
:
4
,
tipoId
:
node
.
t
ypeId
<
4
?
node
.
t
ypeId
+
1
:
4
,
ligiloPosedantoUuid
:
node
?.
uuid
,
};
this
.
dialogMethod
=
this
.
updateKanvasoObjekto
;
...
...
@@ -233,7 +233,7 @@ export default defineComponent({
this
.
dialogMessage
=
'
Удаление элемента
'
;
this
.
payload
=
{
posedantoUzantoId
:
this
.
userId
,
uuid
:
node
.
getU
uid
()
,
uuid
:
node
.
u
uid
,
forigo
:
true
,
};
this
.
dialogMethod
=
this
.
deleteKanvasoObjekto
;
...
...
universo-frontend/src/stores/kanvaso.ts
Просмотр файла @
9c9f4c73
...
...
@@ -19,42 +19,49 @@ import {
import
{
KanvasoEventoj
}
from
'
src/queries/subscriptions.js
'
;
class
ObjectWrapper
{
wrappingObject
:
TreeNode
;
#
wrappingObject
:
TreeNode
;
constructor
(
wrappingObject
:
TreeNode
)
{
this
.
wrappingObject
=
wrappingObject
;
this
.
#
wrappingObject
=
wrappingObject
;
this
.
#
wrappingObject
.
childrens
=
[];
}
get
N
ame
():
string
{
return
this
.
wrappingObject
.
nomo
?.
enhavo
||
'
Без имени
'
;
get
n
ame
():
string
{
return
this
.
#
wrappingObject
.
nomo
?.
enhavo
||
'
Без имени
'
;
}
isPublished
():
boolean
{
return
this
.
wrappingObject
.
publikigo
||
true
;
get
isPublished
():
boolean
{
return
this
.
#
wrappingObject
.
publikigo
||
true
;
}
isDeleted
():
boolean
{
return
this
.
wrappingObject
.
forigo
||
false
;
get
isDeleted
():
boolean
{
return
this
.
#
wrappingObject
.
forigo
||
false
;
}
get
D
escription
():
string
{
return
this
.
wrappingObject
.
priskribo
?.
enhavo
||
'
Нет описания
'
;
get
d
escription
():
string
{
return
this
.
#
wrappingObject
.
priskribo
?.
enhavo
||
'
Нет описания
'
;
}
get
I
d
():
number
{
return
this
.
wrappingObject
.
objId
||
0
;
get
i
d
():
number
{
return
this
.
#
wrappingObject
.
objId
||
0
;
}
get
U
uid
():
string
{
return
this
.
wrappingObject
.
uuid
||
null
;
get
u
uid
():
string
{
return
this
.
#
wrappingObject
.
uuid
||
null
;
}
get
T
ype
():
string
{
return
this
.
wrappingObject
.
tipo
?.
nomo
?.
enhavo
||
'
Без типа
'
;
get
t
ype
():
string
{
return
this
.
#
wrappingObject
.
tipo
?.
nomo
?.
enhavo
||
'
Без типа
'
;
}
get
T
ypeId
():
number
{
return
this
.
wrappingObject
.
tipo
?.
objId
||
0
;
get
t
ypeId
():
number
{
return
this
.
#
wrappingObject
.
tipo
?.
objId
||
0
;
}
get
P
arentUuid
():
string
{
get
p
arentUuid
():
string
{
return
(
this
.
wrappingObject
.
kanvasojKanvasoobjektoligiloLigilo
.
posedanto
?.
uuid
||
this
.
#
wrappingObject
.
kanvasojKanvasoobjektoligiloLigilo
.
posedanto
?.
uuid
||
null
);
}
getChildrens
()
{
return
this
.
wrappingObject
.
children
||
[];
get
childrens
()
{
return
this
.
#
wrappingObject
.
childrens
||
[];
}
setChildrens
(
childrens
:
TreeNode
)
{
this
.
#
wrappingObject
.
childrens
.
push
(
childrens
);
}
get
hasParent
()
{
return
!!
this
.
#
wrappingObject
.
kanvasojKanvasoobjektoligiloLigilo
;
}
}
...
...
@@ -91,17 +98,16 @@ export const useKanvasoStore = defineStore('Kanvaso', {
const
nodeMap
:
Record
<
string
,
TreeNode
>
=
{};
// Инициализируем nodeMap и добавляем каждому узлу пустой массив children и геттеры для получения свойств
nodes
.
forEach
((
node
)
=>
{
node
.
wrappingObject
.
children
=
[];
nodeMap
[
node
.
getUuid
()]
=
node
;
nodeMap
[
node
.
uuid
]
=
node
;
});
// Фильтруем узлы, чтобы сохранить только корневые узлы в результирующем массиве.
const
tree
:
TreeNode
[]
=
nodes
.
filter
((
node
)
=>
{
// Если у узла есть
posedantoUuid
, добавляем его в children его родителя.
if
(
node
.
wrappingObject
.
kanvasojKanvasoobjektoligiloLigilo
)
{
const
parent
=
nodeMap
[
node
.
getP
arentUuid
()
];
// Если у узла есть
uuid родителя
, добавляем его в children его родителя.
if
(
node
.
hasParent
)
{
const
parent
=
nodeMap
[
node
.
p
arentUuid
];
if
(
parent
)
{
parent
.
wrappingObject
.
c
hildren
!
.
push
(
node
);
parent
.
setC
hildren
s
(
node
);
}
// Узел не является корневым, поэтому исключаем его из результирующего массива.
return
false
;
...
...
universo-frontend/src/types/stores/kanvaso.d.ts
Просмотр файла @
9c9f4c73
export
type
TreeNode
=
{
setChildrens
(
node
:
TreeNode
):
TreeNode
[];
getName
:
()
=>
string
;
isPublished
:
()
=>
true
|
boolean
;
isDeleted
:
()
=>
false
|
boolean
;
...
...
@@ -9,6 +10,7 @@ export type TreeNode = {
getUuid
():
string
;
getParentUuid
():
string
;
getChildrens
:
()
=>
[];
hasParent
:
()
=>
boolean
;
wrappingObject
:
TreeNode
;
uuid
:
string
;
forigo
:
boolean
;
...
...
@@ -44,7 +46,7 @@ export type TreeNode = {
tipo
:
Tipo
;
};
children
?:
TreeNode
[];
children
s
?:
TreeNode
[];
};
export
interface
Nomo
{
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать