getDataPart(limit, offset) { var self = this, path = this._apiEndpoint; return api .read(path + '?limit=' + limit + '&offset=' + offset + '&format=table' + self.qFilter); }
drawDimensions() { let self = this, locales, viewAs; return api .read('/cms/language?enabled=true') .then((locs) => { locales = locs.data; return api.read('/view-as'); }) .then((response) => { viewAs = response; return self.options.context(); }) .then((context) => { return Template .redraw('dimensions', { context: context, locale: top.Lackey.manager.locale, variant: top.Lackey.manager.variant, locales: locales, viewAs: viewAs }, self.node); }) .then((root) => { lackey .bind('[data-lky-variant]', 'change', self.viewInVariant.bind(self), root[0]); lackey .bind('[data-lky-locale]', 'change', self.viewInLocale.bind(self), root[0]); lackey .bind('[data-lky-view-as]', 'change', self.viewAs.bind(self), root[0]); }); }
list() { let self = this, query = this.search ? this.search.value : null, url = '/cms/media?limit=4&sort=-createdAt&page=' + self.page; if (query) { url += '&q=' + encodeURIComponent(query); } lackey.unbind('lky:image', 'click', self.onClick, self.root); api .read(url) .then((list) => { if (list.paging.page > 1) { lackey.show(self.prev); } else { lackey.hide(self.prev); } if (list.paging.pages > list.paging.page) { lackey.show(self.next); } else { lackey.hide(self.next); } return template.redraw('list', { uploaded: list.data }, self.root); }) .then(() => { lackey.bind('lky:image', 'click', self.onClick, self.root); }); }
Repository.prototype.load = function (type, id) { let self = this, contentId = type + '-' + id; return api .read('/cms/' + type + '/' + id) .then((content) => { self._cache[contentId] = deepClone(content); self._copy[contentId] = content; }); };
/** * Updates list of pages * @returns {Promise} */ query() { let self = this, input = lackey.select('input[type="search"]', this.node)[0]; api .read('/cms/media?q=' + encodeURI(input.value)) .then((list) => { return template.redraw(lackey.select('[data-lky-hook="settings.gallery"] tbody', self.node)[0], list); }) .then((nodes) => { lackey.bind('[data-lky-btn]', 'click', (event, hook) => { self.resolve(JSON.parse(hook.getAttribute('data-lky-media'))); }, nodes[0]); }); }
/** * Updates list of pages * @returns {Promise} */ query() { let self = this, input = lackey.select('input[type="search"]', this.node)[0]; api .read(self.uri + encodeURI(input.value)) .then(list => { return template.redraw(lackey.select('ul', self.node)[0], list); }) .then(nodes => { lackey.bind('[data-lky-btn]', 'click', (event, hook) => { self.selected(hook); }, nodes[0]); }); }
/** * Updates list of pages * @returns {Promise} */ query(page) { let self = this, input = lackey.select('input[type="search"]', this.node)[0], currentPage = page || 1; api .read('/cms/media?page=' + currentPage + '&limit=6' + '&q=' + encodeURI(input.value)) .then(list => { return template.redraw(lackey.select('[data-lky-hook="settings.gallery"] [data-lky-template]', self.node)[0], list); }) .then(nodes => { lackey.bind('[data-lky-hook=table-paging]', 'click', (event, hook) => { event.preventDefault(); var thisPage = hook.dataset.page; self.query(thisPage); }, nodes[0]); lackey.bind('[data-lky-btn]', 'click', (event, hook) => { self.resolve(JSON.parse(hook.getAttribute('data-lky-media'))); }, nodes[0]); }); }
query(page) { let self = this, input = lackey.select('input[type="search"]', this.node)[0], currentPage = page || 1; api .read(self.uri + encodeURI(input.value) + '&page=' + currentPage) .then(list => { return template.redraw(lackey.select('ul', self.node)[0], list); }) .then(nodes => { lackey.bind('[data-lky-hook=table-paging]', 'click', (event, hook) => { event.preventDefault(); var thisPage = hook.dataset.page; console.log(thisPage); self.query(thisPage); }, nodes[0]); lackey.bind('[data-lky-btn]', 'click', (event, hook) => { self.selected(hook); }, nodes[0]); }); }
static readTemplate(templatePath, index) { if (typeof templatePath === 'object') { return Promise.resolve(templatePath); } cache[templatePath] = cache[templatePath] || api .read('/cms/template?path=' + encodeURI(templatePath) + '&limit=1') .then((data) => { let ctx = {}; if (data && data.data && data.data.length) { ctx = data.data[0]; } return ctx; }); return cache[templatePath] .then((ctx) => { let result = JSON.parse(JSON.stringify(ctx)); result.$idx = index; return result; }); }
query: (text) => { return api .read('/cms/taxonomy?restrictive=1&name=' + encodeURI(text + '%')) .then(data => data.data); },
.then((locs) => { locales = locs.data; return api.read('/view-as'); })