Commit a85a4609 by Иван Кубота

Dropdown z index.

Autoupdate export data on tag add\remove. Format quiz title. Add product search result hint. DOM. add backref element insert ability
parent 9ef1dd74
Pipeline #509 failed with stage
......@@ -68,7 +68,7 @@ const formatters = {
const exportLogic = function(exportEl) {
store.sub(['exportData', 'exportFormat'], function(exportData, exportFormat) {
store.sub(['exportData', 'exportFormat', 'lastUpdate'], function(exportData, exportFormat) {
var arr = [];
var fullData = dP[exportData];
for(var k in fullData){
......
......@@ -171,7 +171,7 @@ const shuffle = function (a) {
const quizGenerator = function(type, photo) {
const cfg = probabilityRand(quizTypes[type+(photo?'Photo':'')]);
const log = ['Quiz generate '+type+(photo ? ' with photo':'') +'. '+(cfg?cfg.type:'FAIL')];
const log = ['Quiz generate '+type+(photo ? ' with photo':'') +' '+(cfg?`„${cfg.type}“`:'. FAIL')];
if(!cfg)
return {answers: [], log};
const source = cfg.from.call(cfg, log),
......
......@@ -134,8 +134,19 @@
D.appendChild = function(el, subEl){
var type = typeof subEl;
if(subEl === null){
return ;
}
if( type !== 'object' ){
if(subEl !== void 0 && subEl !== false){
if( type === 'function' ){
var tmp = D.span( {} );
el.appendChild( tmp );
subEl( function(){
D.removeChildren( tmp );
D.appendChild( tmp, [].slice.call( arguments ) )
} )
}else if( subEl !== void 0 && subEl !== false && subEl !== null ){
el.appendChild( D.Text( subEl ) );
}
}else if('dom' in subEl){
......
......@@ -15,7 +15,7 @@ view.page.Generate = function() {
result = quizGenerator(type, photo);
title.innerText = result.question;
title.innerHTML = textFormat(result.question);
debug.value = result.log.join('\n')
D.removeChildren(answers);
D.appendChild(answers, result.answers.map((a)=>view.cmp.Answer(a, type)));
......@@ -40,7 +40,7 @@ view.page.Generate = function() {
),
div({cls: 'generate-controls'},
D.input({
attr: {type: 'button', value: 'Refresh'},
attr: {type: 'button', value: 'F5'},
on: {click: update}})),
div({cls: 'generate-example'},
......@@ -48,6 +48,8 @@ view.page.Generate = function() {
answers = div({cls: 'generate-answers'}),
debug = D.textarea({cls: 'generate-debug'})
)
);
store.sub(['generateType', 'generatePhoto'], update);
......
......@@ -60,7 +60,7 @@ view.page.Products = function() {
productTable.updateChildByData(item);
});
store.set('lastUpdate', +new Date())
}
}}}),
......@@ -86,11 +86,16 @@ view.page.Products = function() {
dP.Tag.connectToProduct(dP.Product.getByID(item.id), tag);
productTable.updateChildByData(item);
});
store.set('lastUpdate', +new Date())
}
}
}),
D.span({cls: 'tag-manipulations-add-tag__comment'},
_=> store.sub('productFilteredCount', count =>
_(
'Найдено: '+count,
count === 0 ? D.span({}, 'Надо больше результатов!') : (count > 30 ? D.span({}, 'Не цепляй тэг на всё сразу!') : null)
)))
),
productTable = new view.cmp.Table({
sorters: [{id: 'title', type: String}],
......@@ -104,18 +109,18 @@ view.page.Products = function() {
},
afterFilter: (items)=>store.set('productFilteredCount', items.length),
itemTpl: (item, me, bonus) => {
const dom = div({
cls: 'table-item table-item__product',
on: { click: tableAction },
attr:{ 'data-action': 'toggle:'+ item.id}
},
const dom = div({cls: 'table-item table-item__product'},
div( {
cls: 'table-item-action table-item-collapse',
attr: { title: 'Скрыть', 'data-action': 'hide:' + item.id },
on: { click: tableAction }
}, '←' ),
span( { cls: 'product-title' }, me.highlight( item.title ) ),
span( {
cls: 'product-title',
on: { click: tableAction },
attr:{ 'data-action': 'toggle:'+ item.id}
}, me.highlight( item.title ),' ≡' ),
( item.tags || [] ).map( t => me.highlight( dP.tagsHash[ t ].name ) ).map( view.cmp.Tag ),
......
......@@ -2,7 +2,7 @@ body {
font-family: Verdana, Serif;
}
.main-menu, .export-sub-menu {
.main-menu, .export-sub-menu, .generate-sub-menu {
display: flex;
}
......@@ -89,7 +89,9 @@ textarea.export-data {
margin-right: 10%;
margin-bottom: 10px;
}
.export-sub-menu .main-menu-item, .product-filter__title, .product-filter{
.export-sub-menu .main-menu-item,
.product-filter__title, .product-filter,
.generate-sub-menu .main-menu-item{
color: #fff;
}
.main-menu-item {
......@@ -165,6 +167,7 @@ body {margin: 0; padding: 0}
border: 1px solid #158b26;
box-sizing: border-box;
margin-top: -1px;
z-index: 1;
}
.cmp-tag-dropdown-item {
margin: 8px;
......@@ -197,3 +200,29 @@ textarea.generate-debug {
margin: 16px 0 5px 14px;
height: 300px;
}
.tag-manipulations-add-tag__comment {
font-size: 12px
}
.tag-manipulations-add-tag__comment span{
margin-left: 16px
}
.product-title {
cursor: pointer;
}
.generate-title {
font-size: 18px;
margin: 16px
}
.quiz-answer-label {
margin: 16px 32px 16px 16px;
}
.quiz-answer-label input {
margin-right:8px
}
.generate-controls {
margin:16px
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment