mirror of
https://github.com/documize/community.git
synced 2025-07-19 21:29:42 +02:00
re-vamped links to work with tabs
This commit is contained in:
parent
b68a0ac6d6
commit
e7c4b2f40b
13 changed files with 86 additions and 79 deletions
|
@ -41,11 +41,11 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
|||
let self = this;
|
||||
|
||||
$("a[data-documize='true']").off('click').on('click', function (e) {
|
||||
let link = links.getLinkObject(self.get('meta.outboundLinks'), this);
|
||||
let link = links.getLinkObject(self.get('links'), this);
|
||||
|
||||
// local link? exists?
|
||||
if (link.linkType === "section" && link.documentId === doc.get('id')) {
|
||||
let exists = self.get('pages').findBy('id', link.targetId);
|
||||
if ((link.linkType === "section" || link.linkType === "tab") && link.documentId === doc.get('id')) {
|
||||
let exists = self.get('allPages').findBy('id', link.targetId);
|
||||
|
||||
if (_.isUndefined(exists)) {
|
||||
link.orphan = true;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
|
@ -22,10 +22,10 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
|||
this.audit.record("edited-page");
|
||||
|
||||
return Ember.RSVP.hash({
|
||||
folder: self.get('folderService').getFolder(self.paramsFor('document').folder_id),
|
||||
document: self.modelFor('document'),
|
||||
folder: self.modelFor('document').folder,
|
||||
document: self.modelFor('document').document,
|
||||
page: self.get('documentService').getPage(self.paramsFor('document').document_id, params.page_id),
|
||||
meta: self.get('documentService').getPageMeta(self.paramsFor('document').document_id, params.page_id)
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-rout
|
|||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
documentService: Ember.inject.service('document'),
|
||||
linkService: Ember.inject.service('link'),
|
||||
folderService: Ember.inject.service('folder'),
|
||||
userService: Ember.inject.service('user'),
|
||||
queryParams: {
|
||||
|
@ -34,23 +35,32 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
|||
this.set('document', document);
|
||||
this.set('folders', folders);
|
||||
this.set('folder', folder);
|
||||
|
||||
return new Ember.RSVP.Promise((resolve) => {
|
||||
this.get('documentService').getPages(this.get('documentId')).then((pages) => {
|
||||
this.set('allPages', pages);
|
||||
this.set('pages', pages.filterBy('pageType', 'section'));
|
||||
this.set('tabs', pages.filterBy('pageType', 'tab'));
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
model() {
|
||||
this.browser.setTitle(this.get('document.name'));
|
||||
this.browser.setMetaDescription(this.get('document.excerpt'));
|
||||
|
||||
let self = this;
|
||||
|
||||
return Ember.RSVP.hash({
|
||||
folders: self.get('folders'),
|
||||
folder: self.get('folder'),
|
||||
document: self.get('document'),
|
||||
page: self.get('pageId'),
|
||||
isEditor: self.get('folderService').get('canEditCurrentFolder'),
|
||||
pages: self.get('documentService').getPages(self.get('documentId')).then(function (pages) {
|
||||
return pages.filterBy('pageType', 'section');
|
||||
})
|
||||
folders: this.get('folders'),
|
||||
folder: this.get('folder'),
|
||||
document: this.get('document'),
|
||||
page: this.get('pageId'),
|
||||
isEditor: this.get('folderService').get('canEditCurrentFolder'),
|
||||
allPages: this.get('allPages'),
|
||||
pages: this.get('pages'),
|
||||
tabs: this.get('tabs'),
|
||||
links: this.get('linkService').getDocumentLinks(this.get('documentId'))
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
{{document/document-view document=model.document meta=meta pages=model.pages folder=model.folder folders=model.folders isEditor=model.isEditor
|
||||
{{document/document-view document=model.document links=model.links allPages=model.allPages tabs=model.tabs pages=model.pages folder=model.folder folders=model.folders isEditor=model.isEditor
|
||||
gotoPage=(action 'gotoPage') onDeletePage=(action 'onPageDeleted')}}
|
||||
|
|
|
@ -9,7 +9,6 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
this.transitionToRoute('document');
|
||||
},
|
||||
|
||||
|
||||
onAddSection(section) {
|
||||
this.audit.record("added-section-" + section.get('contentType'));
|
||||
|
||||
|
@ -50,43 +49,5 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
// zonAddSection(section) {
|
||||
// this.audit.record("added-section-" + section.get('contentType'));
|
||||
//
|
||||
// let page = {
|
||||
// documentId: this.get('model.document.id'),
|
||||
// title: `${section.get('title')}`,
|
||||
// level: 1,
|
||||
// sequence: 0,
|
||||
// body: "",
|
||||
// contentType: section.get('contentType'),
|
||||
// pageType: section.get('pageType')
|
||||
// };
|
||||
//
|
||||
// let data = this.get('store').normalize('page', page);
|
||||
// let pageData = this.get('store').push(data);
|
||||
//
|
||||
// let meta = {
|
||||
// documentId: this.get('model.document.id'),
|
||||
// rawBody: "",
|
||||
// config: ""
|
||||
// };
|
||||
//
|
||||
// let pageMeta = this.get('store').normalize('page-meta', meta);
|
||||
// let pageMetaData = this.get('store').push(pageMeta);
|
||||
//
|
||||
// let model = {
|
||||
// page: pageData,
|
||||
// meta: pageMetaData
|
||||
// };
|
||||
//
|
||||
// this.get('documentService').addPage(this.get('model.document.id'), model).then((newPage) => {
|
||||
// let options = {};
|
||||
// options['mode'] = 'edit';
|
||||
// this.transitionToRoute('document.section', newPage.id, { queryParams: options });
|
||||
// });
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,11 +21,19 @@ export default Ember.Service.extend({
|
|||
appMeta: service(),
|
||||
store: service(),
|
||||
|
||||
// Returns links within specified document
|
||||
getDocumentLinks(documentId) {
|
||||
return this.get('ajax').request(`documents/${documentId}/links`, {
|
||||
method: "GET"
|
||||
});
|
||||
},
|
||||
|
||||
// Returns candidate links using provided parameters
|
||||
getCandidates(folderId, documentId, pageId) {
|
||||
return this.get('ajax').request(`links/${folderId}/${documentId}/${pageId}`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
console.log(response);
|
||||
return response;
|
||||
});
|
||||
},
|
||||
|
@ -56,7 +64,7 @@ export default Ember.Service.extend({
|
|||
let endpoint = this.get('appMeta').get('endpoint');
|
||||
let orgId = this.get('appMeta').get('orgId');
|
||||
|
||||
if (link.linkType === "section" || link.linkType === "document") {
|
||||
if (link.linkType === "section" || link.linkType === "tab" || link.linkType === "document") {
|
||||
href = `/link/${link.linkType}/${link.id}`;
|
||||
result = `<a data-documize='true' data-link-space-id='${link.folderId}' data-link-id='${link.id}' data-link-target-document-id='${link.documentId}' data-link-target-id='${link.targetId}' data-link-type='${link.linkType}' href='${href}'>${link.title}</a>`;
|
||||
}
|
||||
|
@ -112,6 +120,14 @@ export default Ember.Service.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
// handle tab link
|
||||
if (link.linkType === "tab") {
|
||||
let options = {};
|
||||
options['mode'] = 'view';
|
||||
router.transitionTo('document.section', link.targetId, { queryParams: options });
|
||||
return;
|
||||
}
|
||||
|
||||
// handle document link
|
||||
if (link.linkType === "document") {
|
||||
router.transitionTo('document', link.folderId, folderSlug, link.documentId, documentSlug);
|
||||
|
@ -125,7 +141,3 @@ export default Ember.Service.extend({
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
doc meta to show inbound and outbound links.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<div class="edit-tools">
|
||||
|
||||
<ul class="toolbar">
|
||||
<li class="item">
|
||||
<div class="square-button-mono button-gray" id="content-linker-button" data-tooltip="Reference link" data-tooltip-position="left middle">
|
||||
|
@ -80,5 +79,4 @@
|
|||
</form>
|
||||
</div>
|
||||
{{/dropdown-dialog}}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -142,6 +142,40 @@ func GetDocumentMeta(w http.ResponseWriter, r *http.Request) {
|
|||
writeSuccessBytes(w, json)
|
||||
}
|
||||
|
||||
// GetDocumentLinks is an endpoint returning the links for a document.
|
||||
func GetDocumentLinks(w http.ResponseWriter, r *http.Request) {
|
||||
method := "GetDocumentLinks"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
params := mux.Vars(r)
|
||||
id := params["documentID"]
|
||||
|
||||
if len(id) == 0 {
|
||||
writeMissingDataError(w, method, "documentID")
|
||||
return
|
||||
}
|
||||
|
||||
oLinks, err := p.GetDocumentOutboundLinks(id)
|
||||
|
||||
if len(oLinks) == 0 {
|
||||
oLinks = []entity.Link{}
|
||||
}
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
writeGeneralSQLError(w, method, err)
|
||||
return
|
||||
}
|
||||
|
||||
json, err := json.Marshal(oLinks)
|
||||
|
||||
if err != nil {
|
||||
writeJSONMarshalError(w, method, "link", err)
|
||||
return
|
||||
}
|
||||
|
||||
writeSuccessBytes(w, json)
|
||||
}
|
||||
|
||||
// GetDocumentsByFolder is an endpoint that returns the documents in a given folder.
|
||||
func GetDocumentsByFolder(w http.ResponseWriter, r *http.Request) {
|
||||
method := "GetDocumentsByFolder"
|
||||
|
|
|
@ -74,7 +74,7 @@ func GetLinkCandidates(w http.ResponseWriter, r *http.Request) {
|
|||
FolderID: folderID,
|
||||
DocumentID: documentID,
|
||||
TargetID: p.RefID,
|
||||
LinkType: "section",
|
||||
LinkType: p.PageType,
|
||||
Title: p.Title,
|
||||
}
|
||||
pc = append(pc, c)
|
||||
|
|
|
@ -215,6 +215,7 @@ func init() {
|
|||
// Links
|
||||
log.IfErr(Add(RoutePrefixPrivate, "links/{folderID}/{documentID}/{pageID}", []string{"GET", "OPTIONS"}, nil, GetLinkCandidates))
|
||||
log.IfErr(Add(RoutePrefixPrivate, "links", []string{"GET", "OPTIONS"}, nil, SearchLinkCandidates))
|
||||
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/links", []string{"GET", "OPTIONS"}, nil, GetDocumentLinks))
|
||||
|
||||
// Global installation-wide config
|
||||
log.IfErr(Add(RoutePrefixPrivate, "global", []string{"GET", "OPTIONS"}, nil, GetGlobalConfig))
|
||||
|
|
|
@ -237,10 +237,8 @@ func (p *PageMeta) SetDefaults() {
|
|||
|
||||
// DocumentMeta details who viewed the document.
|
||||
type DocumentMeta struct {
|
||||
Viewers []DocumentMetaViewer `json:"viewers"`
|
||||
Editors []DocumentMetaEditor `json:"editors"`
|
||||
InboundLinks []Link `json:"inboundLinks"`
|
||||
OutboundLinks []Link `json:"outboundLinks"`
|
||||
Viewers []DocumentMetaViewer `json:"viewers"`
|
||||
Editors []DocumentMetaEditor `json:"editors"`
|
||||
}
|
||||
|
||||
// DocumentMetaViewer contains the "view" metatdata content.
|
||||
|
|
|
@ -107,13 +107,6 @@ func (p *Persister) GetDocumentMeta(id string) (meta entity.DocumentMeta, err er
|
|||
return
|
||||
}
|
||||
|
||||
meta.OutboundLinks, err = p.GetDocumentOutboundLinks(id)
|
||||
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Unable to execute GetDocumentOutboundLinks for document %s", id), err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ func (p *Persister) SearchLinkCandidates(keywords string) (docs []entity.LinkCan
|
|||
temp = []entity.LinkCandidate{}
|
||||
|
||||
err = Db.Select(&temp,
|
||||
`SELECT p.refid as targetid, p.documentid as documentid, p.title as title, d.title as context, d.labelid as folderid from page p
|
||||
`SELECT p.refid as targetid, p.documentid as documentid, p.title as title, p.pagetype as linktype, d.title as context, d.labelid as folderid from page p
|
||||
LEFT JOIN document d ON d.refid=p.documentid WHERE p.orgid=? AND `+likeQuery+` AND d.labelid IN
|
||||
(SELECT refid from label WHERE orgid=? AND type=2 AND userid=?
|
||||
UNION ALL SELECT refid FROM label a where orgid=? AND type=1 AND refid IN (SELECT labelid from labelrole WHERE orgid=? AND userid='' AND (canedit=1 OR canview=1))
|
||||
|
@ -120,7 +120,7 @@ func (p *Persister) SearchLinkCandidates(keywords string) (docs []entity.LinkCan
|
|||
FolderID: r.FolderID,
|
||||
DocumentID: r.DocumentID,
|
||||
TargetID: r.TargetID,
|
||||
LinkType: "section",
|
||||
LinkType: r.LinkType,
|
||||
Title: r.Title,
|
||||
Context: r.Context,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue