Update
This commit is contained in:
45
myapp/mutations/tag.py
Normal file
45
myapp/mutations/tag.py
Normal file
@@ -0,0 +1,45 @@
|
||||
__author__ = 'RemiZOffAlex'
|
||||
__email__ = 'remizoffalex@mail.ru'
|
||||
|
||||
import logging
|
||||
|
||||
from .. import lib, models
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def tag_as_dict(
|
||||
tag: models.Tag,
|
||||
fields: list = ['id', 'name']
|
||||
):
|
||||
"""Тег в словарь
|
||||
"""
|
||||
def field_pages(tag):
|
||||
# Теги
|
||||
result = []
|
||||
for tagLink in tag.tags:
|
||||
newTag = tagLink.tag.as_dict()
|
||||
result.append(newTag)
|
||||
return result
|
||||
|
||||
def field_user(tag):
|
||||
# Пользователь
|
||||
return tag.user.as_dict()
|
||||
|
||||
funcs = {
|
||||
'pages': field_pages,
|
||||
'user': field_user,
|
||||
}
|
||||
result = {}
|
||||
|
||||
for column in tag.__table__.columns:
|
||||
if column.name in fields:
|
||||
result[column.name] = getattr(tag, column.name)
|
||||
|
||||
for field in fields:
|
||||
if field in funcs:
|
||||
func = funcs[field]
|
||||
result[field] = func(tag)
|
||||
|
||||
return result
|
||||
@@ -4,7 +4,7 @@ __email__ = 'remizoffalex@mail.ru'
|
||||
|
||||
|
||||
from . import ( # noqa F401
|
||||
common,
|
||||
note,
|
||||
page,
|
||||
tag
|
||||
)
|
||||
|
||||
@@ -4,6 +4,25 @@ __email__ = 'remizoffalex@mail.ru'
|
||||
|
||||
from .. import jsonrpc, login_required
|
||||
from ... import models
|
||||
from ...mutations.tag import tag_as_dict
|
||||
|
||||
@jsonrpc.method('tag')
|
||||
def tag_id(
|
||||
id: int,
|
||||
fields: list = ['id', 'name']
|
||||
) -> dict:
|
||||
"""Тег
|
||||
"""
|
||||
tag = models.db_session.query(
|
||||
models.Tag
|
||||
).filter(
|
||||
models.Tag.id == id
|
||||
).first()
|
||||
if tag is None:
|
||||
raise ValueError
|
||||
|
||||
result = tag_as_dict(tag, fields)
|
||||
return result
|
||||
|
||||
|
||||
@jsonrpc.method('tag.add')
|
||||
@@ -62,7 +62,12 @@ def tag_page_delete(tag: int, id: int) -> bool:
|
||||
|
||||
|
||||
@jsonrpc.method('tag.pages')
|
||||
def tag_pages_list(id: int, page: int) -> list:
|
||||
def tag_pages_list(
|
||||
id: int,
|
||||
page: int = 1,
|
||||
order_by: dict = {'field': 'title', 'order': 'asc'},
|
||||
fields: list = ['id', 'title', 'tags', 'user']
|
||||
) -> list:
|
||||
"""Список статей
|
||||
"""
|
||||
tag = models.db_session.query(
|
||||
@@ -81,9 +86,19 @@ def tag_pages_list(id: int, page: int) -> list:
|
||||
models.Page
|
||||
).filter(
|
||||
models.Page.id.in_(indexes)
|
||||
).order_by(
|
||||
models.Page.title.asc()
|
||||
)
|
||||
|
||||
# Сортировка
|
||||
if order_by['field'] not in ['created', 'id', 'title', 'updated']:
|
||||
raise ValueError
|
||||
if order_by['order'] not in ['asc', 'desc']:
|
||||
raise ValueError
|
||||
field = getattr(models.Page, order_by['field'])
|
||||
order = getattr(field, order_by['order'])
|
||||
pages = pages.order_by(
|
||||
order()
|
||||
)
|
||||
|
||||
pages = lib.getpage(
|
||||
pages,
|
||||
page,
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
{% extends "private/skeleton.html" %}
|
||||
{% block content %}
|
||||
|
||||
{% raw %}
|
||||
<h3>
|
||||
<a class="btn btn-outline-secondary" href="/tags"><i class="fa fa-chevron-left"></i></a>
|
||||
Тег {{ tag.name }}</h3>
|
||||
<hr />
|
||||
{% endraw %}
|
||||
{% include '/user/tag_menu.html' %}
|
||||
|
||||
<pagination-component v-bind:pagination="pagination" v-bind:click-handler="getPages"></pagination-component>
|
||||
|
||||
{% include '/inc/pages.html' %}
|
||||
|
||||
<pagination-component v-bind:pagination="pagination" v-bind:click-handler="getPages"></pagination-component>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{% raw %}
|
||||
<ol class="breadcrumb mt-3">
|
||||
<li class="breadcrumb-item"><a href="/"><i class="fa fa-home"></i></a></li>
|
||||
<li class="breadcrumb-item"><a href="/tags">Список тегов</a></li>
|
||||
<li class="breadcrumb-item">{{ tag.name }}</li>
|
||||
</ol>
|
||||
{% endraw %}
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script type="text/javascript">
|
||||
Object.assign(root.data, {
|
||||
menuitem: null,
|
||||
tag: {{ pagedata['tag']|tojson|safe }},
|
||||
raw_pages: [],
|
||||
pagination: {{ pagedata['pagination']|tojson|safe }},
|
||||
});
|
||||
Object.assign(root.methods, {
|
||||
getPages: function() {
|
||||
/* Получить список статей */
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.pages",
|
||||
"params": {
|
||||
"id": vm.tag.id,
|
||||
"page": vm.pagination.page
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data) {
|
||||
vm.raw_pages = response.data['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
root.created = function() {
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
[
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.pages",
|
||||
"params": {
|
||||
"id": vm.tag.id,
|
||||
"page": vm.pagination.page
|
||||
},
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.pages.count",
|
||||
"params": {
|
||||
"id": vm.tag.id
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
]
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data[0]) {
|
||||
vm.raw_pages = response.data[0]['result'];
|
||||
}
|
||||
if ('result' in response.data[1]) {
|
||||
vm.pagination.size = response.data[1]['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
Object.assign(root.computed, {
|
||||
pages: function() {
|
||||
let vm = this;
|
||||
return vm.raw_pages;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,14 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
|
||||
<div class="btn-group">
|
||||
<div class="btn btn-primary mb-2" v-if="menuitem===null"><i class="fa fa-bars"></i></div>
|
||||
<a class="btn btn-outline-secondary mb-2" :href="'/tag/' + tag.id" v-else><i class="fa fa-bars"></i></a>
|
||||
</div>
|
||||
|
||||
<div class="btn btn-primary mb-2" v-if="menuitem==='notes'">Заметки</div>
|
||||
<a class="btn btn-outline-secondary mb-2" :href="'/tag/' + tag.id + '/notes'" v-else>Заметки</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
@@ -1,105 +0,0 @@
|
||||
{% extends "private/skeleton.html" %}
|
||||
{% block content %}
|
||||
|
||||
{% raw %}
|
||||
<h3>
|
||||
<a class="btn btn-outline-secondary" href="/tags"><i class="fa fa-chevron-left"></i></a>
|
||||
Тег {{ tag.name }}</h3>
|
||||
<hr />
|
||||
{% endraw %}
|
||||
|
||||
{% include 'user/tag_menu.html' %}
|
||||
|
||||
<pagination-component v-bind:pagination="pagination" v-bind:click-handler="getNotes"></pagination-component>
|
||||
|
||||
{% include '/inc/notes.html' %}
|
||||
|
||||
<pagination-component v-bind:pagination="pagination" v-bind:click-handler="getNotes"></pagination-component>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{% raw %}
|
||||
<ol class="breadcrumb mt-3">
|
||||
<li class="breadcrumb-item"><a href="/"><i class="fa fa-home"></i></a></li>
|
||||
<li class="breadcrumb-item"><a href="/tags">Список тегов</a></li>
|
||||
<li class="breadcrumb-item">{{ tag.name }}</li>
|
||||
<li class="breadcrumb-item">Заметки с тегом</li>
|
||||
</ol>
|
||||
{% endraw %}
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script type="text/javascript" src="/static/components/pagination.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
Object.assign(root.data, {
|
||||
menuitem: 'notes',
|
||||
tag: {{ pagedata['tag']|tojson|safe }},
|
||||
raw_notes: [],
|
||||
pagination: {{ pagedata['pagination']|tojson|safe }},
|
||||
});
|
||||
Object.assign(root.methods, {
|
||||
getNotes: function() {
|
||||
/* Получить список статей */
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.notes",
|
||||
"params": {
|
||||
"id": vm.tag.id,
|
||||
"page": vm.pagination.page
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data) {
|
||||
vm.raw_notes = response.data['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
root.created = function() {
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
[
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.notes",
|
||||
"params": {
|
||||
"id": vm.tag.id,
|
||||
"page": vm.pagination.page
|
||||
},
|
||||
"id": 1
|
||||
},
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "tag.notes.count",
|
||||
"params": {},
|
||||
"id": 1
|
||||
}
|
||||
]
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data[0]) {
|
||||
vm.raw_notes = response.data[0]['result'];
|
||||
}
|
||||
if ('result' in response.data[1]) {
|
||||
vm.pagination.size = response.data[1]['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
Object.assign(root.computed, {
|
||||
notes: function() {
|
||||
let vm = this;
|
||||
return vm.raw_notes;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -1,115 +0,0 @@
|
||||
{% extends "private/skeleton.html" %}
|
||||
{% block content %}
|
||||
|
||||
<h3>
|
||||
<div class="btn btn-outline-success float-right" v-on:click="showFormNewTag"><i class="fa fa-plus"></i></div>
|
||||
Список тегов</h3>
|
||||
<hr />
|
||||
|
||||
{% raw %}
|
||||
<div class="form-group mt-3" v-if="formNewTag">
|
||||
<div class="input-group mb-3">
|
||||
<input class="form-control" type="text" v-model="newTag"/>
|
||||
<div class="input-group-append">
|
||||
<div class="btn btn-outline-success float-right" v-on:click="addTag"><i class="fa fa-save"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col py-2">
|
||||
<div class="btn-group mr-2 mb-3" v-for="(tag, tagIdx) in tags">
|
||||
<a class="btn btn-outline-secondary" :href="'/tag/' + tag.id">{{ tag.name }}</a>
|
||||
<button type="button" class="btn btn-outline-danger" v-on:click="deleteTag(tag)"><i class="fa fa-remove"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endraw %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
<ol class="breadcrumb mt-3">
|
||||
<li class="breadcrumb-item"><a href="/"><i class="fa fa-home"></i></a></li>
|
||||
<li class="breadcrumb-item">Список тегов</li>
|
||||
</ol>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script type="text/javascript">
|
||||
Object.assign(root.data, {
|
||||
tags: [],
|
||||
formNewTag: false,
|
||||
newTag: ''
|
||||
});
|
||||
Object.assign(root.methods, {
|
||||
addTag: function() {
|
||||
/* Добавить тег */
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": 'tag.add',
|
||||
"params": {
|
||||
"name": vm.newTag
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data) {
|
||||
vm.tags.push(response.data['result']);
|
||||
vm.newTag = '';
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
showFormNewTag: function() {
|
||||
/* Показать/скрыть форму добавления нового тега */
|
||||
let vm = this;
|
||||
vm.formNewTag = !vm.formNewTag;
|
||||
},
|
||||
deleteTag: function(tag) {
|
||||
/* Удалить тег */
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": 'tag.delete',
|
||||
"params": {
|
||||
"id": tag.id
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data) {
|
||||
vm.tags = vm.arrayRemove(vm.tags, tag);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
root.created = function() {
|
||||
/* Получить список тегов после загрузки страницы */
|
||||
let vm = this;
|
||||
axios.post(
|
||||
'/api',
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": 'tags',
|
||||
"params": {},
|
||||
"id": 1
|
||||
}
|
||||
).then(
|
||||
function(response) {
|
||||
if ('result' in response.data) {
|
||||
vm.tags = response.data['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -12,7 +12,7 @@ def tags():
|
||||
"""
|
||||
pagedata = {}
|
||||
pagedata['title'] = 'Список меток - ' + app.config['TITLE']
|
||||
body = render_template('user/tags.html', pagedata=pagedata)
|
||||
body = render_template('/private/skeleton.html', pagedata=pagedata)
|
||||
return body
|
||||
|
||||
|
||||
@@ -32,15 +32,8 @@ def tag_id(id):
|
||||
tag.name,
|
||||
app.config['TITLE']
|
||||
)
|
||||
pagedata['tag'] = tag.as_dict()
|
||||
|
||||
pagedata['pagination'] = {
|
||||
"page": 1,
|
||||
"per_page": app.config['ITEMS_ON_PAGE'],
|
||||
"size": 0
|
||||
}
|
||||
|
||||
body = render_template('user/tag.html', pagedata=pagedata)
|
||||
body = render_template('/private/skeleton.html', pagedata=pagedata)
|
||||
return body
|
||||
|
||||
|
||||
@@ -60,13 +53,6 @@ def tag_notes(id):
|
||||
tag.name,
|
||||
app.config['TITLE']
|
||||
)
|
||||
pagedata['tag'] = tag.as_dict()
|
||||
|
||||
pagedata['pagination'] = {
|
||||
"page": 1,
|
||||
"per_page": app.config['ITEMS_ON_PAGE'],
|
||||
"size": 0
|
||||
}
|
||||
|
||||
body = render_template('user/tag_notes.html', pagedata=pagedata)
|
||||
body = render_template('/private/skeleton.html', pagedata=pagedata)
|
||||
return body
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{% extends "skeleton.html" %}
|
||||
{% if user %}
|
||||
{% extends "/public/skeleton.html" %}
|
||||
{% else %}
|
||||
{% extends "/private/skeleton.html" %}
|
||||
{% endif %}
|
||||
{% block content %}
|
||||
|
||||
<h3 class="text-danger">{{ error_code }}: {{ error_message }}</h3>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% include '/public/domains/tag/menu.js' %}
|
||||
{% include '/public/domains/tag/pages.js' %}
|
||||
{% include '/public/domains/tag/tag.js' %}
|
||||
{% include '/public/domains/tag/tags.js' %}
|
||||
|
||||
@@ -5,6 +7,8 @@ Object.assign(
|
||||
routes,
|
||||
{
|
||||
"/tag/:id": layout_decorator(Tag),
|
||||
"/tag/:id/pages": layout_decorator(TagPages),
|
||||
"/tag/:id/pages/:page": layout_decorator(TagPages),
|
||||
"/tags": layout_decorator(Tags),
|
||||
}
|
||||
);
|
||||
|
||||
45
myapp/templates/public/domains/tag/menu.js
Normal file
45
myapp/templates/public/domains/tag/menu.js
Normal file
@@ -0,0 +1,45 @@
|
||||
function MenuTag() {
|
||||
let data = {
|
||||
menuitem: null,
|
||||
tag: null,
|
||||
};
|
||||
function button_common() {
|
||||
if (data.menuitem===null) {
|
||||
return {tag: '<', children: '<div class="btn btn-primary me-2"><i class="fa fa-bars"></i></div>'};
|
||||
} else {
|
||||
return m(m.route.Link, {class: "btn btn-outline-secondary me-2 text-decoration-none", href: `/tag/${data.tag.id}`, title: data.tag.name}, m('i', {class: 'fa fa-bars'}))
|
||||
}
|
||||
};
|
||||
function button_pages() {
|
||||
if (data.menuitem==='pages') {
|
||||
return {tag: '<', children: '<div class="btn btn-primary me-2"">Статьи</div>'};
|
||||
} else {
|
||||
return m(m.route.Link, {class: "btn btn-outline-secondary me-2 text-decoration-none", href: `/tag/${data.tag.id}/pages`}, 'Статьи')
|
||||
}
|
||||
};
|
||||
return {
|
||||
oninit: function(vnode) {
|
||||
console.log('MenuTag.oninit');
|
||||
for (let key in vnode.attrs){
|
||||
data[key] = vnode.attrs[key];
|
||||
};
|
||||
},
|
||||
onupdate: function(vnode) {
|
||||
console.log('MenuTag.onupdate');
|
||||
for (let key in vnode.attrs){
|
||||
data[key] = vnode.attrs[key];
|
||||
};
|
||||
},
|
||||
view: function(vnode) {
|
||||
console.log('MenuTag.view');
|
||||
if (data.tag!=null) {
|
||||
return m('div', {class: 'row'},
|
||||
m('div', {class: 'col py-2'}, [
|
||||
button_common(),
|
||||
button_pages(),
|
||||
]),
|
||||
);
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
162
myapp/templates/public/domains/tag/pages.js
Normal file
162
myapp/templates/public/domains/tag/pages.js
Normal file
@@ -0,0 +1,162 @@
|
||||
function TagPages() {
|
||||
let data = {
|
||||
filter: PanelFilter(),
|
||||
order_by: PanelOrderBy({
|
||||
field: 'title',
|
||||
fields: [
|
||||
{value: 'id', text: 'ID'},
|
||||
{value: 'title', text: 'заголовку'},
|
||||
{value: 'created', text: 'дате создания'},
|
||||
{value: 'updated', text: 'дате обновления'}
|
||||
],
|
||||
clickHandler: pages_get,
|
||||
order: 'asc',
|
||||
}),
|
||||
tag: null,
|
||||
raw_pages: [],
|
||||
get pages() {
|
||||
let result = data.raw_pages.filter(page_filter);
|
||||
return result;
|
||||
},
|
||||
pagination: {
|
||||
page: 1,
|
||||
size: 0,
|
||||
prefix_url: '/pages'
|
||||
},
|
||||
};
|
||||
function breadcrumbs_render() {
|
||||
let result = m('ul', {class: 'breadcrumb mt-2'}, [
|
||||
m('li', {class: 'breadcrumb-item'}, m(m.route.Link, {href: '/'}, m('i', {class: 'fa fa-home'}))),
|
||||
m('li', {class: 'breadcrumb-item'}, m(m.route.Link, {href: '/tags'}, 'Список тегов')),
|
||||
m('li', {class: 'breadcrumb-item'}, m(m.route.Link, {href: `/tag/${data.tag.id}`}, data.tag.name)),
|
||||
m('li', {class: 'breadcrumb-item active'}, 'Список статей'),
|
||||
]);
|
||||
return result;
|
||||
};
|
||||
function page_filter(page) {
|
||||
let filter = data.filter.data;
|
||||
let value = filter.value;
|
||||
if ( value.length<1 ) {
|
||||
return true;
|
||||
}
|
||||
if ( page.title.toLowerCase().includes(value.toLowerCase()) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
function tag_get(id) {
|
||||
m.request({
|
||||
url: '/api',
|
||||
method: "POST",
|
||||
body: {
|
||||
"jsonrpc": "2.0",
|
||||
"method": 'tag',
|
||||
"params": {
|
||||
"id": id
|
||||
},
|
||||
"id": get_id()
|
||||
}
|
||||
}).then(
|
||||
function(response) {
|
||||
if ('result' in response) {
|
||||
data.tag = response['result'];
|
||||
data.pagination.prefix_url = `/tag/${data.tag.id}/pages`;
|
||||
document.title = `Статьи с тегом [${data.tag.name}`;
|
||||
pages_get();
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
function pages_get() {
|
||||
m.request({
|
||||
url: '/api',
|
||||
method: "POST",
|
||||
body: [
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": 'tag.pages',
|
||||
"params": {
|
||||
"id": data.tag.id,
|
||||
"page": data.pagination.page,
|
||||
"order_by": data.order_by.value,
|
||||
"fields": ["id", "title", "tags"]
|
||||
},
|
||||
"id": get_id()
|
||||
},
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": 'tag.pages.count',
|
||||
"params": {
|
||||
"id": data.tag.id,
|
||||
},
|
||||
"id": get_id()
|
||||
}
|
||||
]
|
||||
|
||||
}).then(
|
||||
function(response) {
|
||||
if ('result' in response[0]) {
|
||||
data.raw_pages = response[0]['result'];
|
||||
}
|
||||
if ('result' in response[1]) {
|
||||
data.pagination.size = response[1]['result'];
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return {
|
||||
oninit: function(vnode) {
|
||||
console.log('TagPages.oninit');
|
||||
if (vnode.attrs.page!==undefined) {
|
||||
data.pagination.page = Number(vnode.attrs.page);
|
||||
};
|
||||
tag_get(vnode.attrs.id);
|
||||
},
|
||||
onbeforeupdate: function(vnode) {
|
||||
console.log('TagPages.onbeforeupdate');
|
||||
if (vnode.attrs.page!==undefined) {
|
||||
if (data.pagination.page.toString() != vnode.attrs.page) {
|
||||
data.pagination.page = Number(vnode.attrs.page);
|
||||
pages_get();
|
||||
}
|
||||
};
|
||||
},
|
||||
view: function(vnode) {
|
||||
console.log('TagPages.view');
|
||||
result = [];
|
||||
if (data.tag!=null) {
|
||||
result.push(
|
||||
breadcrumbs_render(),
|
||||
m('div', {class: 'row'},
|
||||
m('div', {class: 'col h1 py-2'}, [
|
||||
m('div', {class: "btn-group btn-group-lg me-2"}, [
|
||||
m(m.route.Link, {class: "btn btn-outline-secondary", href: `/tag/${data.tag.id}`, title: "Вернуться"}, m('i', {class: "fa fa-chevron-left"})),
|
||||
m('button', {type: "button", class: "btn btn-outline-secondary", onclick: function() { panel_show(data.filter.data) }},
|
||||
m('i', {class: "fa fa-filter"})
|
||||
),
|
||||
m('button', {type: "button", class: "btn btn-outline-secondary", onclick: function() { panel_show(data.order_by.data) }},
|
||||
m('i', {class: "fa fa-sort-alpha-asc"})
|
||||
)
|
||||
]),
|
||||
`Статьи с тегом [${data.tag.name}]`
|
||||
]),
|
||||
m('hr'),
|
||||
)
|
||||
);
|
||||
|
||||
// result.push(m(MenuTag, {menuitem: 'pages', tag: data.tag}));
|
||||
result.push({tag: MenuTag, attrs: {menuitem: 'pages', tag: data.tag}});
|
||||
|
||||
result.push(m(data.filter));
|
||||
result.push(m(data.order_by));
|
||||
result.push(m(Pagination, data.pagination));
|
||||
if (data.pages.length>0) {
|
||||
result.push(m(ComponentPages, {pages: data.pages}));
|
||||
result.push(m(Pagination, data.pagination));
|
||||
};
|
||||
result.push(breadcrumbs_render());
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -58,17 +58,6 @@ function Tag() {
|
||||
// result.push(m(MenuTag, {"tag1": data.tag}));
|
||||
result.push({ tag: MenuTag, attrs: { tag: data.tag } });
|
||||
|
||||
result.push(
|
||||
m('div', { class: 'row' }, [
|
||||
m('div', { class: "col-md-4 py-2" },
|
||||
m(m.route.Link, { class: "btn btn-outline-secondary btn-lg w-100", href: `/tag/${data.tag.id}/notes` }, 'Заметки с тегом'),
|
||||
),
|
||||
m('div', { class: "col-md-4 py-2" },
|
||||
m(m.route.Link, { class: "btn btn-outline-secondary btn-lg w-100", href: `/tag/${data.tag.id}/pages` }, 'Статьи с тегом'),
|
||||
),
|
||||
])
|
||||
);
|
||||
|
||||
result.push(
|
||||
m('div', { class: 'row' },
|
||||
m('div', { class: "col py-2" }, m.trust(data.tag.description)),
|
||||
|
||||
Reference in New Issue
Block a user