Highlight the page until it's saved
This commit is contained in:
		@ -1,3 +1,7 @@
 | 
				
			|||||||
 | 
					#app-navigation:not(.vue) > ul > li > a[data-id].modified {
 | 
				
			||||||
 | 
						color:red;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
li[data-id="wikis"] select {
 | 
					li[data-id="wikis"] select {
 | 
				
			||||||
	width: calc(100% - 50px);
 | 
						width: calc(100% - 50px);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -33,6 +33,9 @@ class WikiContent {
 | 
				
			|||||||
                                    },
 | 
					                                    },
 | 
				
			||||||
                                    element: this.textarea,
 | 
					                                    element: this.textarea,
 | 
				
			||||||
                                    hideIcons:[],
 | 
					                                    hideIcons:[],
 | 
				
			||||||
 | 
					                                    insertTexts:{
 | 
				
			||||||
 | 
					                                        image:['']
 | 
				
			||||||
 | 
					                                    },
 | 
				
			||||||
                                    minHeight:height+"px",
 | 
					                                    minHeight:height+"px",
 | 
				
			||||||
                                    maxHeight:height+"px",
 | 
					                                    maxHeight:height+"px",
 | 
				
			||||||
                                    sideBySideFullscreen: false,
 | 
					                                    sideBySideFullscreen: false,
 | 
				
			||||||
@ -48,7 +51,7 @@ class WikiContent {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            console.log(changeObj);
 | 
					            console.log(changeObj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var event = new CustomEvent("myWiki::change", {myWiki:{ wikiId:self.wikiId,pageId:self.pageId }});
 | 
					            var event = new CustomEvent("myWiki::change", {detail:{ wikiId:self.wikiId,pageId:self.pageId }});
 | 
				
			||||||
            document.dispatchEvent(event);
 | 
					            document.dispatchEvent(event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            clearTimeout(self.timeout);
 | 
					            clearTimeout(self.timeout);
 | 
				
			||||||
@ -122,25 +125,27 @@ class WikiContent {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    save(content) {
 | 
					    save(content) {
 | 
				
			||||||
        const self = this;
 | 
					        const wikiId = this.wikiId;
 | 
				
			||||||
        console.info(`JDG :: Saving wiki page ${self.wikiId}-${self.pageId}`);
 | 
					        const pageId = this.pageId;
 | 
				
			||||||
        if (self.wikiId<=0 || self.pageId<=0) {
 | 
					
 | 
				
			||||||
 | 
					        console.info(`JDG :: Saving wiki page ${wikiId}-${pageId}`);
 | 
				
			||||||
 | 
					        if (wikiId<=0 || pageId<=0) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var baseUrl = OC.generateUrl('/apps/mywiki/wiki/'+self.wikiId);
 | 
					        var baseUrl = OC.generateUrl('/apps/mywiki/wiki/'+wikiId);
 | 
				
			||||||
        $.ajax({
 | 
					        $.ajax({
 | 
				
			||||||
            url: baseUrl+'/'+self.pageId,
 | 
					            url: baseUrl+'/'+pageId,
 | 
				
			||||||
            type: 'PUT',
 | 
					            type: 'PUT',
 | 
				
			||||||
            contentType: 'application/json',
 | 
					            contentType: 'application/json',
 | 
				
			||||||
            data: JSON.stringify({title:null, content:content})
 | 
					            data: JSON.stringify({title:null, content:content})
 | 
				
			||||||
        }).done(function (response) {
 | 
					        }).done(function (response) {
 | 
				
			||||||
            console.info(`JDG :: WikiContent.save(${self.wikiId}, ${self.pageId})`, response);
 | 
					            console.info(`JDG :: WikiContent.save(${wikiId}, ${pageId})`, response);
 | 
				
			||||||
            var event = new CustomEvent("myWiki::saved", {myWiki:{ wikiId:self.wikiId,pageId:self.pageId }});
 | 
					            var event = new CustomEvent("myWiki::saved", {detail:{ wikiId:wikiId,pageId:pageId }});
 | 
				
			||||||
            document.dispatchEvent(event);
 | 
					            document.dispatchEvent(event);
 | 
				
			||||||
        }).fail(function (response, code) {
 | 
					        }).fail(function (response, code) {
 | 
				
			||||||
            OC.dialogs.alert('Error', t(appName,'Error saving wiki page({wikiId}, {pageId})',{wikiId:self.wikiId,pageId:self.pageId}));
 | 
					            OC.dialogs.alert('Error', t(appName,'Error saving wiki page({wikiId}, {pageId})',{wikiId:wikiId,pageId:pageId}));
 | 
				
			||||||
            console.error(`JDG :: WikiContent.save(${self.wikiId}, ${self.pageId})`, response);
 | 
					            console.error(`JDG :: WikiContent.save(${wikiId}, ${pageId})`, response);
 | 
				
			||||||
        }); 
 | 
					        }); 
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -5,15 +5,18 @@ class WikiPages {
 | 
				
			|||||||
    * The container is the <ul> for the navigation panel
 | 
					    * The container is the <ul> for the navigation panel
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
    constructor(container, onClickLoadPage) {
 | 
					    constructor(container, onClickLoadPage) {
 | 
				
			||||||
 | 
					        const self = this;
 | 
				
			||||||
        this.ul = container;
 | 
					        this.ul = container;
 | 
				
			||||||
        this._onClickLoadPage = onClickLoadPage;
 | 
					        this._onClickLoadPage = onClickLoadPage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        document.addEventListener("myWiki::change", function(e) {
 | 
					        document.addEventListener("myWiki::change", function(e) {
 | 
				
			||||||
            console.log("myWiki::change",e.myWiki);
 | 
					            console.log("myWiki::change",e.detail);
 | 
				
			||||||
 | 
					            self.ul.querySelector(`li[data-page-id="${e.detail.pageId}"] a`).classList.add('modified');
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
       document.addEventListener("myWiki::saved", function(e) {
 | 
					       document.addEventListener("myWiki::saved", function(e) {
 | 
				
			||||||
            console.log("myWiki::saved", e.myWiki);
 | 
					            console.log("myWiki::saved", e.detail);
 | 
				
			||||||
          });
 | 
					            self.ul.querySelector(`li[data-page-id="${e.detail.pageId}"] a`).classList.remove('modified');
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -21,7 +24,7 @@ class WikiPages {
 | 
				
			|||||||
        this.wikiId = null;
 | 
					        this.wikiId = null;
 | 
				
			||||||
        this.ul.querySelectorAll('[data-page-id]').forEach( x=>x.remove() );
 | 
					        this.ul.querySelectorAll('[data-page-id]').forEach( x=>x.remove() );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        document.querySelectorAll('#app-navigation .active').forEach(e=>e.class.remove('.active'))
 | 
					        document.querySelectorAll('#app-navigation .active').forEach(e=>e.class.remove('active'))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    getWikiId() {
 | 
					    getWikiId() {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user