MOBILE-3105 wiki: Code restyling
parent
10328b7582
commit
3f1114f34c
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
<!-- Content. -->
|
<!-- Content. -->
|
||||||
<core-loading [hideUntil]="loaded" class="core-loading-center">
|
<core-loading [hideUntil]="loaded" class="core-loading-center">
|
||||||
<div padding class="addon-mod_wiki-page-content">
|
<div padding *ngIf="(isMainPage && description) || pageIsOffline || hasOffline || pageWarning">
|
||||||
<core-course-module-description *ngIf="isMainPage" [description]="description" [component]="component" [componentId]="componentId"></core-course-module-description>
|
<core-course-module-description *ngIf="isMainPage" [description]="description" [component]="component" [componentId]="componentId"></core-course-module-description>
|
||||||
|
|
||||||
<!-- Wiki has something offline. -->
|
<!-- Wiki has something offline. -->
|
||||||
|
@ -39,7 +39,8 @@
|
||||||
<ion-icon name="warning"></ion-icon>
|
<ion-icon name="warning"></ion-icon>
|
||||||
{{ pageWarning }}
|
{{ pageWarning }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div padding class="addon-mod_wiki-page-content">
|
||||||
<article [ngClass]="{'addon-mod_wiki-noedit': !canEdit}">
|
<article [ngClass]="{'addon-mod_wiki-noedit': !canEdit}">
|
||||||
<core-format-text *ngIf="pageContent" [component]="component" [componentId]="componentId" [text]="pageContent"></core-format-text>
|
<core-format-text *ngIf="pageContent" [component]="component" [componentId]="componentId" [text]="pageContent"></core-format-text>
|
||||||
<core-empty-box *ngIf="!pageContent" icon="document" [message]="'addon.mod_wiki.nocontent' | translate" [inline]="true"></core-empty-box>
|
<core-empty-box *ngIf="!pageContent" icon="document" [message]="'addon.mod_wiki.nocontent' | translate" [inline]="true"></core-empty-box>
|
||||||
|
|
|
@ -12,6 +12,7 @@ ion-app.app-root addon-mod-wiki-index {
|
||||||
|
|
||||||
.addon-mod_wiki-page-content {
|
.addon-mod_wiki-page-content {
|
||||||
background-color: $white;
|
background-color: $white;
|
||||||
|
border-top: 1px solid $gray;
|
||||||
@include darkmode() {
|
@include darkmode() {
|
||||||
background-color: $black;
|
background-color: $black;
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,31 +145,20 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
protected checkPageCreatedOrDiscarded(data: any): void {
|
protected checkPageCreatedOrDiscarded(data: any): void {
|
||||||
if (!this.currentPage && data) {
|
if (!this.currentPage && data) {
|
||||||
// This is an offline page. Check if the page was created.
|
// This is an offline page. Check if the page was created.
|
||||||
let pageId;
|
const page = data.created.find((page) => page.title == this.pageTitle);
|
||||||
|
if (page) {
|
||||||
for (let i = 0, len = data.created.length; i < len; i++) {
|
|
||||||
const page = data.created[i];
|
|
||||||
if (page.title == this.pageTitle) {
|
|
||||||
pageId = page.pageId;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pageId) {
|
|
||||||
// Page was created, set the ID so it's retrieved from server.
|
// Page was created, set the ID so it's retrieved from server.
|
||||||
this.currentPage = pageId;
|
this.currentPage = page.pageId;
|
||||||
this.pageIsOffline = false;
|
this.pageIsOffline = false;
|
||||||
} else {
|
} else {
|
||||||
// Page not found in created list, check if it was discarded.
|
// Page not found in created list, check if it was discarded.
|
||||||
for (let i = 0, len = data.discarded.length; i < len; i++) {
|
const page = data.discarded.find((page) => page.title == this.pageTitle);
|
||||||
const page = data.discarded[i];
|
if (page) {
|
||||||
if (page.title == this.pageTitle) {
|
// Page discarded, show warning.
|
||||||
// Page discarded, show warning.
|
this.pageWarning = page.warning;
|
||||||
this.pageWarning = page.warning;
|
this.pageContent = '';
|
||||||
this.pageContent = '';
|
this.pageIsOffline = false;
|
||||||
this.pageIsOffline = false;
|
this.hasOffline = false;
|
||||||
this.hasOffline = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,12 +317,9 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
|
|
||||||
// If no page specified, search first page.
|
// If no page specified, search first page.
|
||||||
if (!this.currentPage && !this.pageTitle) {
|
if (!this.currentPage && !this.pageTitle) {
|
||||||
for (const i in subwikiPages) {
|
const firstPage = subwikiPages.find((page) => page.firstpage );
|
||||||
const page = subwikiPages[i];
|
if (firstPage) {
|
||||||
if (page.firstpage) {
|
this.currentPage = firstPage.id;
|
||||||
this.currentPage = page.id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,7 +513,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
*
|
*
|
||||||
* @param page Page to view.
|
* @param page Page to view.
|
||||||
*/
|
*/
|
||||||
goToPage(page: any): void {
|
protected goToPage(page: any): void {
|
||||||
if (!page.id) {
|
if (!page.id) {
|
||||||
// It's an offline page. Check if we are already in the same offline page.
|
// It's an offline page. Check if we are already in the same offline page.
|
||||||
if (this.currentPage || !this.pageTitle || page.title != this.pageTitle) {
|
if (this.currentPage || !this.pageTitle || page.title != this.pageTitle) {
|
||||||
|
@ -536,8 +522,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
courseId: this.courseId,
|
courseId: this.courseId,
|
||||||
pageTitle: page.title,
|
pageTitle: page.title,
|
||||||
wikiId: this.wiki.id,
|
wikiId: this.wiki.id,
|
||||||
subwikiId: page.subwikiid,
|
subwikiId: page.subwikiid
|
||||||
action: 'page'
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -551,8 +536,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
pageTitle: page.title,
|
pageTitle: page.title,
|
||||||
pageId: page.id,
|
pageId: page.id,
|
||||||
wikiId: page.wikiid,
|
wikiId: page.wikiid,
|
||||||
subwikiId: page.subwikiid,
|
subwikiId: page.subwikiid
|
||||||
action: 'page'
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -563,9 +547,9 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
/**
|
/**
|
||||||
* Show the map.
|
* Show the map.
|
||||||
*
|
*
|
||||||
* @param {MouseEvent} event Event.
|
* @param event Event.
|
||||||
*/
|
*/
|
||||||
openMap(event: MouseEvent): void {
|
openMap(event?: MouseEvent): void {
|
||||||
const modal = this.modalCtrl.create('AddonModWikiMapPage', {
|
const modal = this.modalCtrl.create('AddonModWikiMapPage', {
|
||||||
pages: this.subwikiPages,
|
pages: this.subwikiPages,
|
||||||
selected: this.currentPageObj && this.currentPageObj.id,
|
selected: this.currentPageObj && this.currentPageObj.id,
|
||||||
|
@ -576,7 +560,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
enterAnimation: 'core-modal-lateral-transition',
|
enterAnimation: 'core-modal-lateral-transition',
|
||||||
leaveAnimation: 'core-modal-lateral-transition' });
|
leaveAnimation: 'core-modal-lateral-transition' });
|
||||||
|
|
||||||
// If the modal sends back a SCO, load it.
|
// If the modal sends back a page, load it.
|
||||||
modal.onDidDismiss((page) => {
|
modal.onDidDismiss((page) => {
|
||||||
if (page) {
|
if (page) {
|
||||||
if (page.type == 'home') {
|
if (page.type == 'home') {
|
||||||
|
@ -984,9 +968,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
|
|
||||||
if (multiLevelList) {
|
if (multiLevelList) {
|
||||||
// As we loop over each subwiki, add it to the current group
|
// As we loop over each subwiki, add it to the current group
|
||||||
for (const i in subwikiList) {
|
subwikiList.forEach((subwiki) => {
|
||||||
const subwiki = subwikiList[i];
|
|
||||||
|
|
||||||
// Should we create a new grouping?
|
// Should we create a new grouping?
|
||||||
if (subwiki.groupid !== groupValue) {
|
if (subwiki.groupid !== groupValue) {
|
||||||
grouping = {label: subwiki.groupLabel, subwikis: []};
|
grouping = {label: subwiki.groupLabel, subwikis: []};
|
||||||
|
@ -997,16 +979,14 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
|
|
||||||
// Add the subwiki to the currently active grouping.
|
// Add the subwiki to the currently active grouping.
|
||||||
grouping.subwikis.push(subwiki);
|
grouping.subwikis.push(subwiki);
|
||||||
}
|
});
|
||||||
} else if (showMyGroupsLabel) {
|
} else if (showMyGroupsLabel) {
|
||||||
const noGrouping = {label: '', subwikis: []},
|
const noGrouping = {label: '', subwikis: []},
|
||||||
myGroupsGrouping = {label: this.translate.instant('core.mygroups'), subwikis: []},
|
myGroupsGrouping = {label: this.translate.instant('core.mygroups'), subwikis: []},
|
||||||
otherGroupsGrouping = {label: this.translate.instant('core.othergroups'), subwikis: []};
|
otherGroupsGrouping = {label: this.translate.instant('core.othergroups'), subwikis: []};
|
||||||
|
|
||||||
// As we loop over each subwiki, add it to the current group
|
// As we loop over each subwiki, add it to the current group
|
||||||
for (const i in subwikiList) {
|
subwikiList.forEach((subwiki) => {
|
||||||
const subwiki = subwikiList[i];
|
|
||||||
|
|
||||||
// Add the subwiki to the currently active grouping.
|
// Add the subwiki to the currently active grouping.
|
||||||
if (typeof subwiki.canedit == 'undefined') {
|
if (typeof subwiki.canedit == 'undefined') {
|
||||||
noGrouping.subwikis.push(subwiki);
|
noGrouping.subwikis.push(subwiki);
|
||||||
|
@ -1015,7 +995,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
} else {
|
} else {
|
||||||
otherGroupsGrouping.subwikis.push(subwiki);
|
otherGroupsGrouping.subwikis.push(subwiki);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Add each grouping to the subwikis
|
// Add each grouping to the subwikis
|
||||||
if (noGrouping.subwikis.length > 0) {
|
if (noGrouping.subwikis.length > 0) {
|
||||||
|
|
|
@ -21,7 +21,10 @@
|
||||||
</ion-item-divider>
|
</ion-item-divider>
|
||||||
<a ion-item text-wrap *ngFor="let page of letter.pages" (click)="goToPage(page)" [class.core-nav-item-selected]="selected == page.id">
|
<a ion-item text-wrap *ngFor="let page of letter.pages" (click)="goToPage(page)" [class.core-nav-item-selected]="selected == page.id">
|
||||||
<ion-icon name="home" item-start *ngIf="page.firstpage"></ion-icon> {{ page.title }}
|
<ion-icon name="home" item-start *ngIf="page.firstpage"></ion-icon> {{ page.title }}
|
||||||
<ion-note *ngIf="!page.id" item-end color="danger">{{ 'core.offline' | translate }}</ion-note>
|
<ion-note *ngIf="!page.id" item-end>
|
||||||
|
<ion-icon name="time"></ion-icon>
|
||||||
|
<span text-wrap>{{ 'core.notsent' | translate }}</span>
|
||||||
|
</ion-note>
|
||||||
</a>
|
</a>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
|
|
|
@ -38,7 +38,7 @@ export class AddonModWikiMapPage {
|
||||||
/**
|
/**
|
||||||
* Function called when a page is clicked.
|
* Function called when a page is clicked.
|
||||||
*
|
*
|
||||||
* @param {any} page Clicked page.
|
* @param page Clicked page.
|
||||||
*/
|
*/
|
||||||
goToPage(page: any): void {
|
goToPage(page: any): void {
|
||||||
this.viewCtrl.dismiss({type: 'page', goto: page});
|
this.viewCtrl.dismiss({type: 'page', goto: page});
|
||||||
|
@ -54,7 +54,7 @@ export class AddonModWikiMapPage {
|
||||||
/**
|
/**
|
||||||
* Construct the map of pages.
|
* Construct the map of pages.
|
||||||
*
|
*
|
||||||
* @param {any[]} pages List of pages.
|
* @param pages List of pages.
|
||||||
*/
|
*/
|
||||||
protected constructMap(pages: any[]): void {
|
protected constructMap(pages: any[]): void {
|
||||||
let letter,
|
let letter,
|
||||||
|
|
Loading…
Reference in New Issue