MOBILE-3105 wiki: Code restyling

main
Pau Ferrer Ocaña 2019-08-30 09:44:36 +02:00
parent 10328b7582
commit 3f1114f34c
5 changed files with 33 additions and 48 deletions

View File

@ -24,7 +24,7 @@
<!-- Content. -->
<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>
<!-- Wiki has something offline. -->
@ -39,7 +39,8 @@
<ion-icon name="warning"></ion-icon>
{{ pageWarning }}
</div>
</div>
<div padding class="addon-mod_wiki-page-content">
<article [ngClass]="{'addon-mod_wiki-noedit': !canEdit}">
<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>

View File

@ -12,6 +12,7 @@ ion-app.app-root addon-mod-wiki-index {
.addon-mod_wiki-page-content {
background-color: $white;
border-top: 1px solid $gray;
@include darkmode() {
background-color: $black;
}

View File

@ -145,25 +145,15 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
protected checkPageCreatedOrDiscarded(data: any): void {
if (!this.currentPage && data) {
// This is an offline page. Check if the page was created.
let pageId;
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) {
const page = data.created.find((page) => page.title == this.pageTitle);
if (page) {
// Page was created, set the ID so it's retrieved from server.
this.currentPage = pageId;
this.currentPage = page.pageId;
this.pageIsOffline = false;
} else {
// 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[i];
if (page.title == this.pageTitle) {
const page = data.discarded.find((page) => page.title == this.pageTitle);
if (page) {
// Page discarded, show warning.
this.pageWarning = page.warning;
this.pageContent = '';
@ -173,7 +163,6 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
}
}
}
}
/**
* Get the wiki data.
@ -328,12 +317,9 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
// If no page specified, search first page.
if (!this.currentPage && !this.pageTitle) {
for (const i in subwikiPages) {
const page = subwikiPages[i];
if (page.firstpage) {
this.currentPage = page.id;
break;
}
const firstPage = subwikiPages.find((page) => page.firstpage );
if (firstPage) {
this.currentPage = firstPage.id;
}
}
@ -527,7 +513,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
*
* @param page Page to view.
*/
goToPage(page: any): void {
protected goToPage(page: any): void {
if (!page.id) {
// It's an offline page. Check if we are already in the same offline page.
if (this.currentPage || !this.pageTitle || page.title != this.pageTitle) {
@ -536,8 +522,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
courseId: this.courseId,
pageTitle: page.title,
wikiId: this.wiki.id,
subwikiId: page.subwikiid,
action: 'page'
subwikiId: page.subwikiid
});
return;
@ -551,8 +536,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
pageTitle: page.title,
pageId: page.id,
wikiId: page.wikiid,
subwikiId: page.subwikiid,
action: 'page'
subwikiId: page.subwikiid
});
});
@ -563,9 +547,9 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
/**
* Show the map.
*
* @param {MouseEvent} event Event.
* @param event Event.
*/
openMap(event: MouseEvent): void {
openMap(event?: MouseEvent): void {
const modal = this.modalCtrl.create('AddonModWikiMapPage', {
pages: this.subwikiPages,
selected: this.currentPageObj && this.currentPageObj.id,
@ -576,7 +560,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
enterAnimation: '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) => {
if (page) {
if (page.type == 'home') {
@ -984,9 +968,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
if (multiLevelList) {
// As we loop over each subwiki, add it to the current group
for (const i in subwikiList) {
const subwiki = subwikiList[i];
subwikiList.forEach((subwiki) => {
// Should we create a new grouping?
if (subwiki.groupid !== groupValue) {
grouping = {label: subwiki.groupLabel, subwikis: []};
@ -997,16 +979,14 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
// Add the subwiki to the currently active grouping.
grouping.subwikis.push(subwiki);
}
});
} else if (showMyGroupsLabel) {
const noGrouping = {label: '', subwikis: []},
myGroupsGrouping = {label: this.translate.instant('core.mygroups'), subwikis: []},
otherGroupsGrouping = {label: this.translate.instant('core.othergroups'), subwikis: []};
// As we loop over each subwiki, add it to the current group
for (const i in subwikiList) {
const subwiki = subwikiList[i];
subwikiList.forEach((subwiki) => {
// Add the subwiki to the currently active grouping.
if (typeof subwiki.canedit == 'undefined') {
noGrouping.subwikis.push(subwiki);
@ -1015,7 +995,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
} else {
otherGroupsGrouping.subwikis.push(subwiki);
}
}
});
// Add each grouping to the subwikis
if (noGrouping.subwikis.length > 0) {

View File

@ -21,7 +21,10 @@
</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">
<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>
</ng-container>
</ion-list>

View File

@ -38,7 +38,7 @@ export class AddonModWikiMapPage {
/**
* Function called when a page is clicked.
*
* @param {any} page Clicked page.
* @param page Clicked page.
*/
goToPage(page: any): void {
this.viewCtrl.dismiss({type: 'page', goto: page});
@ -54,7 +54,7 @@ export class AddonModWikiMapPage {
/**
* Construct the map of pages.
*
* @param {any[]} pages List of pages.
* @param pages List of pages.
*/
protected constructMap(pages: any[]): void {
let letter,