Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kus-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
kus-admin
Commits
79a0a904
Commit
79a0a904
authored
Feb 01, 2020
by
talequale
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
f7e9b5d9
29212d95
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
47 deletions
+79
-47
Store.js
src/core/data/store/Store.js
+15
-1
Store.js
src/model/Store.js
+2
-1
Header.jsx
src/view/block/header/Header.jsx
+2
-1
Header.scss
src/view/block/header/Header.scss
+1
-0
CardSlider.jsx
src/view/cmp/cardSlider/CardSlider.jsx
+0
-0
Account.jsx
src/view/page/account/Account.jsx
+59
-44
No files found.
src/core/data/store/Store.js
View file @
79a0a904
...
...
@@ -246,11 +246,25 @@ Store.OR = Store.AGGREGATE(function(values, length) {
}
return
result
;
});
Store
.
ELSE
=
function
(){
if
(
!
(
this
instanceof
Store
.
ELSE
))
return
new
Store
.
ELSE
()};
Store
.
IF
=
function
(
cfg
,
children
){
var
holders
=
{
true
:
[],
false
:
[]},
holder
=
holders
.
true
;
for
(
var
i
=
0
,
_i
=
children
.
length
;
i
<
_i
;
i
++
){
var
child
=
children
[
i
];
if
(
child
instanceof
Store
.
ELSE
){
holder
=
holders
.
false
;
}
else
{
holder
.
push
(
child
);
}
}
holders
.
true
.
length
===
0
&&
(
holders
.
true
=
null
);
holders
.
false
.
length
===
0
&&
(
holders
.
false
=
null
);
return
function
(
update
){
if
(
'condition'
in
cfg
)
var
hook
=
function
(
cond
){
update
(
cond
?
children
:
null
);
update
(
cond
?
holders
.
true
:
holders
.
false
);
};
if
(
cfg
.
condition
instanceof
HookPrototype
){
cfg
.
condition
.
hook
(
hook
);
...
...
src/model/Store.js
View file @
79a0a904
...
...
@@ -78,7 +78,8 @@ const tmpStore = new Store({
loaded
:
false
,
navigation
:
{
current
:
'Login'
},
isMobile
:
false
,
width
:
window
.
innerWidth
width
:
window
.
innerWidth
,
newItemCount
:
1000
});
let
lastNav
=
null
;
...
...
src/view/block/header/Header.jsx
View file @
79a0a904
...
...
@@ -4,6 +4,7 @@ import Logo from '/svg/logo.svg';
import
User
from
"/svg/user.svg"
;
import
Logout
from
"/svg/logout.svg"
;
import
{
Page
}
from
"../../page/Page"
;
import
Input
from
"../../cmp/field/Input"
;
const
{
IF
,
NOT
}
=
Store
;
const
Header
=
D
.
declare
(
'view.block.Header'
,
()
=>
{
...
...
@@ -49,7 +50,7 @@ const Header = D.declare('view.block.Header', () => {
{
name
}
</
button
>
)
}
</
div
>
}
<
div
>
New cards count
<
Input
type=
{
'number'
}
bind=
{
tmpStore
.
bind
(
'newItemCount'
)
}
/></
div
><
/
div
>
</
div
>
<
IF
condition=
{
NOT
(
store
.
valEqual
(
'navigation.current'
,
'Login'
))
}
>
<
div
className=
"page-header__wrapper"
>
...
...
src/view/block/header/Header.scss
View file @
79a0a904
...
...
@@ -144,6 +144,7 @@
top
:
0
;
left
:
0
;
z-index
:
1
;
background
:
rgba
(
0
,
0
,
100
,
0
.4
);
.hidden
{
display
:
none
;
}
...
...
src/view/cmp/cardSlider/CardSlider.jsx
View file @
79a0a904
This diff is collapsed.
Click to expand it.
src/view/page/account/Account.jsx
View file @
79a0a904
...
...
@@ -5,38 +5,49 @@ import {API} from "../../../dict/Consts";
import
Card
from
"../../cmp/card/Card"
;
import
CardSlider
from
"../../cmp/cardSlider/CardSlider"
;
import
AccountNavigation
from
"../../block/accountNav/AccountNavigation"
;
const
{
IF
,
ELSE
}
=
Store
;
const
Account
=
D
.
declare
(
'view.page.Account'
,
()
=>
{
const
showSlider
=
new
Store
.
Value
.
Boolean
(
true
);
// subscribe to new cards
store
.
sub
(
[
'loaded.cards'
,
tmpStore
.
bind
(
'afterNavigation.to'
),
tmpStore
.
bind
(
'newCardsLoaded'
),
tmpStore
.
bind
(
'newItemCount'
)
],
function
(
loadedCards
,
to
,
newCardsLoaded
,
newItemCount
){
let
stamp
=
[
loadedCards
,
newItemCount
].
join
(
';'
);
if
(
newCardsLoaded
!==
stamp
){
if
(
loadedCards
&&
to
===
'Account'
){
const
newCards
=
cards
.
getArray
()
.
filter
(
card
=>
card
.
seen
===
false
)
.
sort
(
(
a
,
b
)
=>
a
.
id
-
b
.
id
)
.
slice
(
0
,
newItemCount
);
// finally we get new cards!
showSlider
.
set
(
newCards
.
length
);
Slider
.
setItems
(
newCards
);
tmpStore
.
set
(
'newCardsLoaded'
,
stamp
)
}
}
}
);
let
Slider
=
new
CardSlider
(
{
name
:
"newCardsSlider"
,
itemClick
:
(
item
,
action
)
=>
{
action
.
execute
(
item
);
},
items
:
_
=>
store
.
sub
(
[
'loaded.cards'
,
'navigation.current'
,
tmpStore
.
bind
(
'afterNavigation.to'
),
tmpStore
.
bind
(
'newCardsLoaded'
),
],
function
(
loadedCards
,
to
,
newCardsLoaded
){
if
(
newCardsLoaded
!==
loadedCards
){
if
(
loadedCards
&&
to
===
'Account'
){
_
(
cards
.
getArray
()
.
filter
(
card
=>
card
.
seen
===
false
)
.
sort
(
(
a
,
b
)
=>
a
.
id
-
b
.
id
)
);
tmpStore
.
set
(
'newCardsLoaded'
,
loadedCards
)
}
}
}
)
}
}
);
const
dom
=
<
div
class=
"account-page"
>
...
...
@@ -51,29 +62,33 @@ const Account = D.declare('view.page.Account', () => {
<
div
class=
"account-page__content-inner"
>
<
div
class=
"account-page__cards"
>
<
h2
class=
"account-page__title"
>
Новые карточки для вашей должности:
</
h2
>
{
Slider
}
<
IF
condition=
{
showSlider
}
>
{
Slider
}
<
ELSE
/>
<
div
className=
"account-page__no-cards"
>
<
div
className=
"account-page__no-cards-info"
>
<
div
className=
"account-page__no-cards-item"
>
<
Card
type=
{
'product'
}
disabled
title=
{
'Карточек нет'
}
image=
{
'/uploads/images/card-disabled.png'
}
/>
</
div
>
<
div
className=
"account-page__no-cards-text"
>
<
p
>
Вы
просмотрели все новые карточки этого месяца.
</
p
>
<
p
>
Так держать!
</
p
>
</
div
>
<
div
className=
"account-page__no-cards-info"
>
<
div
className=
"account-page__no-cards-item"
>
<
Card
type=
{
'product'
}
disabled
title=
{
'Карточек нет'
}
image=
{
'/uploads/images/card-disabled.png'
}
/>
</
div
>
<
div
className=
"account-page__no-cards-image"
>
<
picture
>
<
source
srcset=
"uploads/images/assistant-nocards-mob.svg"
media=
{
"(max-width: 767px"
}
/>
<
img
src=
"uploads/images/assistant-nocards.svg"
alt=
""
/>
</
picture
>
<
div
className=
"account-page__no-cards-text"
>
<
p
>
Вы
просмотрели все новые карточки этого месяца.
</
p
>
<
p
>
Так держать!
</
p
>
</
div
>
</
div
>
<
div
className=
"account-page__no-cards-image"
>
<
picture
>
<
source
srcSet=
"uploads/images/assistant-nocards-mob.svg"
media=
{
"(max-width: 767px"
}
/>
<
img
src=
"uploads/images/assistant-nocards.svg"
alt=
""
/>
</
picture
>
</
div
>
</
div
>
</
IF
>
<
div
className=
"account-page__nav"
>
<
AccountNavigation
/>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment