return of the document dialog at /document/<id>

This commit is contained in:
j 2017-01-25 22:01:40 +01:00
parent b829faf5d6
commit df60dca85f
9 changed files with 31 additions and 20 deletions

View file

@ -1258,7 +1258,7 @@
"page": "", "page": "",
"part": { "part": {
"api": "", "api": "",
"documents": "", "document": "",
"entities": "", "entities": "",
"faq": "", "faq": "",
"help": "", "help": "",

View file

@ -1743,6 +1743,7 @@
"page": "", "page": "",
"part": { "part": {
"api": "", "api": "",
"document": "",
"entities": "", "entities": "",
"faq": "", "faq": "",
"help": "", "help": "",

View file

@ -1205,6 +1205,7 @@
"page": "", "page": "",
"part": { "part": {
"api": "", "api": "",
"document": "",
"entities": "", "entities": "",
"faq": "", "faq": "",
"help": "", "help": "",

View file

@ -1159,6 +1159,7 @@ examples (config.SITENAME.jsonc) that are part of this pan.do/ra distribution.
"page": "", "page": "",
"part": { "part": {
"api": "", "api": "",
"document": "",
"entities": "", "entities": "",
"faq": "", "faq": "",
"help": "", "help": "",

View file

@ -20,15 +20,13 @@ pandora.URL = (function() {
Ox.contains(Object.keys(pandora.site.user.ui.part), state.page) Ox.contains(Object.keys(pandora.site.user.ui.part), state.page)
) { ) {
state.part = pandora.user.ui.part[state.page]; state.part = pandora.user.ui.part[state.page];
/*
if ( if (
state.page == 'documents' state.page == 'document'
&& pandora.user.ui.documents[state.part] && pandora.user.ui.documents[state.part]
&& pandora.user.ui.documents[state.part].position && pandora.user.ui.documents[state.part].position
) { ) {
state.span = pandora.user.ui.documents[state.part].position; state.span = pandora.user.ui.documents[state.part].position;
} }
*/
} }
} else { } else {
@ -174,6 +172,9 @@ pandora.URL = (function() {
) && state.part) { ) && state.part) {
set['part.' + state.page] = state.part; set['part.' + state.page] = state.part;
} }
if (state.span) {
set['documents.' + state.part] = {position: state.span};
}
pandora.UI.set(set); pandora.UI.set(set);
callback && callback(); callback && callback();
@ -473,7 +474,7 @@ pandora.URL = (function() {
getSort: pandora.getSort, getSort: pandora.getSort,
getSpan: pandora.getSpan, getSpan: pandora.getSpan,
pages: [].concat( pages: [].concat(
['home', 'software', 'api', 'help', 'tv', 'entities'], ['home', 'software', 'api', 'help', 'tv', 'document', 'entities'],
pandora.site.sitePages.map(function(page) { pandora.site.sitePages.map(function(page) {
return page.id; return page.id;
}), }),

View file

@ -71,10 +71,10 @@ pandora.ui.appPanel = function() {
!pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen' !pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen'
](); ]();
pandora.$ui.home && pandora.$ui.tv.mute(); pandora.$ui.home && pandora.$ui.tv.mute();
} else if (page == 'documents') { } else if (page == 'document') {
if (pandora.user.ui.part.documents) { if (pandora.user.ui.part.document) {
pandora.openDocumentDialog({ pandora.openDocumentDialog({
ids: [pandora.user.ui.part.documents.split('/')[0]] ids: [pandora.user.ui.part.document.split('/')[0]]
}); });
} else { } else {
pandora.UI.set({page: ''}); pandora.UI.set({page: ''});

View file

@ -9,7 +9,7 @@ pandora.openDocumentDialog = function(options) {
pandora.$ui.documentDialog && options.ids && options.ids.length == 1 pandora.$ui.documentDialog && options.ids && options.ids.length == 1
&& Ox.getObjectById(pandora.$ui.documentDialog.getItems(), options.ids[0]) && Ox.getObjectById(pandora.$ui.documentDialog.getItems(), options.ids[0])
) { ) {
pandora.UI.set({'part.documents': options.ids[0]}); pandora.UI.set({'part.document': options.ids[0]});
} else if (options.ids) { } else if (options.ids) {
pandora.api.findDocuments({ pandora.api.findDocuments({
query: { query: {
@ -37,7 +37,7 @@ pandora.openDocumentDialog = function(options) {
}) })
.bindEvent({ .bindEvent({
close: function() { close: function() {
pandora.user.ui.page == 'documents' && pandora.UI.set({page: ''}); pandora.user.ui.page == 'document' && pandora.UI.set({page: ''});
} }
}) })
.open(); .open();
@ -48,8 +48,8 @@ pandora.openDocumentDialog = function(options) {
}); });
} }
pandora.UI.set({ pandora.UI.set({
page: 'documents', page: 'document',
'part.documents': options.documents[0].id 'part.document': options.documents[0].id
}); });
return pandora.$ui.documentDialog; return pandora.$ui.documentDialog;
} }

View file

@ -34,7 +34,7 @@ pandora.documentColumns = [
format: function(value, data) { format: function(value, data) {
return Ox.isArray(value) return Ox.isArray(value)
? Ox.formatDimensions(value, 'px') ? Ox.formatDimensions(value, 'px')
: Ox.formatCount(value, data.extension == 'html' ? 'word' : 'page'); : Ox.formatCount(value, (data && data.extension == 'html') ? 'word' : 'page');
}, },
id: 'dimensions', id: 'dimensions',
operator: '-', operator: '-',

View file

@ -1497,9 +1497,14 @@ pandora.getItem = function(state, str, callback) {
} }
}); });
} else if (state.type == 'documents') { } else if (state.type == 'documents') {
pandora.api.getDocument({id: str, keys: ['id']}, function(result) { pandora.api.getDocument({
id: str,
// send keys so that subsequent request when parsing
// page number etc. is already in the cache
keys: ['dimensions', 'extension']
}, function(result) {
if (result.status.code == 200) { if (result.status.code == 200) {
state.item = result.data.id; state.item = str;
callback(); callback();
} else { } else {
state.item = ''; state.item = '';
@ -1808,7 +1813,7 @@ pandora.getPart = function(state, str, callback) {
} else { } else {
callback(); callback();
} }
} else if (state.page == 'documents') { } else if (state.page == 'document') {
var id = str.split('/')[0]; var id = str.split('/')[0];
if (id) { if (id) {
pandora.api.getDocument({ pandora.api.getDocument({
@ -1963,10 +1968,12 @@ pandora.getSpan = function(state, val, callback) {
// modify state.view. // modify state.view.
// fixme: "subtitles:23" is still missing // fixme: "subtitles:23" is still missing
Ox.Log('URL', 'getSpan', state, val); Ox.Log('URL', 'getSpan', state, val);
if (state.type == 'documents') { if (state.page == 'document' || // document dialog
if (state.item) { state.type == 'documents' // document section
) {
if (state.page == 'document' || state.item) {
pandora.api.getDocument({ pandora.api.getDocument({
id: state.item, id: state.page == 'document' ? state.part : state.item,
keys: ['dimensions', 'extension'] keys: ['dimensions', 'extension']
}, function(result) { }, function(result) {
var dimensions = result.data.dimensions, var dimensions = result.data.dimensions,