Merge pull request #1685 from crazyserver/MOBILE-2795

Mobile 2795
main
Juan Leyva 2018-12-20 10:55:20 +01:00 committed by GitHub
commit 30384e9251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 23 deletions

View File

@ -1,7 +1,7 @@
<ion-item-divider color="light">
<h2>{{ 'addon.block_myoverview.pluginname' | translate }}</h2>
<!-- Download all courses. -->
<div *ngIf="downloadAllCoursesEnabled && courses[selectedFilter] && courses[selectedFilter].length > 1" class="core-button-spinner" item-end>
<div *ngIf="downloadAllCoursesEnabled && courses[selectedFilter] && courses[selectedFilter].length > 1 && !showFilter" class="core-button-spinner" item-end>
<button *ngIf="prefetchCoursesData[selectedFilter].icon && prefetchCoursesData[selectedFilter].icon != 'spinner'" ion-button icon-only clear color="dark" (click)="prefetchCourses()">
<core-icon [name]="prefetchCoursesData[selectedFilter].icon"></core-icon>
</button>

View File

@ -177,17 +177,17 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
*/
filterChanged(event: any): void {
const newValue = event.target.value && event.target.value.trim().toLowerCase();
if (!newValue || !this.courses[this.selectedFilter]) {
this.filteredCourses = this.courses[this.selectedFilter];
if (!newValue || !this.courses['all']) {
this.filteredCourses = this.courses['all'];
} else {
// Use displayname if avalaible, or fullname if not.
if (this.courses[this.selectedFilter].length > 0 &&
typeof this.courses[this.selectedFilter][0].displayname != 'undefined') {
this.filteredCourses = this.courses[this.selectedFilter].filter((course) => {
if (this.courses['all'].length > 0 &&
typeof this.courses['all'][0].displayname != 'undefined') {
this.filteredCourses = this.courses['all'].filter((course) => {
return course.displayname.toLowerCase().indexOf(newValue) > -1;
});
} else {
this.filteredCourses = this.courses[this.selectedFilter].filter((course) => {
this.filteredCourses = this.courses['all'].filter((course) => {
return course.fullname.toLowerCase().indexOf(newValue) > -1;
});
}
@ -311,7 +311,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
switchFilter(): void {
this.showFilter = !this.showFilter;
this.courses.filter = '';
this.filteredCourses = this.courses[this.selectedFilter];
this.filteredCourses = this.courses[this.showFilter ? 'all' : this.selectedFilter];
if (this.showFilter) {
setTimeout(() => {
this.searchbar.setFocus();
@ -325,7 +325,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
* @return {boolean} If switch button that enables the filter input is shown or not.
*/
showFilterSwitchButton(): boolean {
return this.loaded && this.courses[this.selectedFilter] && this.courses[this.selectedFilter].length > 5;
return this.loaded && this.courses['all'] && this.courses['all'].length > 5;
}
/**

View File

@ -1,7 +1,8 @@
<ion-header>
<ion-navbar core-back-button>
<ion-title>
<img *ngIf="conversationImage" class="core-bar-button-image" [src]="conversationImage">
<img *ngIf="!otherMember && conversationImage" class="core-bar-button-image" [src]="conversationImage" alt="" onError="this.src='assets/img/user-avatar.png'" core-external-content role="presentation" [siteId]="siteId || null">
<ion-avatar *ngIf="otherMember" class="core-bar-button-image" core-user-avatar [user]="otherMember" [linkProfile]="false" [checkOnline]="otherMember.showonlinestatus" item-start></ion-avatar>
<core-format-text [text]="title"></core-format-text>
<core-icon *ngIf="conversation && conversation.isfavourite" name="fa-star"></core-icon>
</ion-title>
@ -9,15 +10,15 @@
</ion-navbar>
<core-navbar-buttons end>
<core-context-menu>
<core-context-menu-item [hidden]="!showInfo || isGroup" [priority]="1000" [content]="'addon.messages.info' | translate" (action)="viewInfo()"></core-context-menu-item>
<core-context-menu-item [hidden]="!showInfo || !isGroup" [priority]="1000" [content]="'addon.messages.groupinfo' | translate" (action)="viewInfo()"></core-context-menu-item>
<core-context-menu-item [hidden]="!groupMessagingEnabled || !conversation" [priority]="800" [content]="(conversation && conversation.isfavourite ? 'addon.messages.removefromfavourites' : 'addon.messages.addtofavourites') | translate" (action)="changeFavourite($event)" [closeOnClick]="false"></core-context-menu-item>
<core-context-menu-item [hidden]="!otherMember || otherMember.isblocked" [priority]="700" [content]="'addon.messages.blockuser' | translate" (action)="blockUser()"></core-context-menu-item>
<core-context-menu-item [hidden]="!otherMember || !otherMember.isblocked" [priority]="700" [content]="'addon.messages.unblockuser' | translate" (action)="unblockUser()"></core-context-menu-item>
<core-context-menu-item [hidden]="!canDelete" [priority]="400" [content]="'addon.messages.showdeletemessages' | translate" (action)="toggleDelete()"></core-context-menu-item>
<core-context-menu-item [hidden]="!groupMessagingEnabled || !conversationId || isGroup" [priority]="200" [content]="'addon.messages.deleteconversation' | translate" (action)="deleteConversation($event)" [closeOnClick]="false"></core-context-menu-item>
<core-context-menu-item [hidden]="!otherMember || otherMember.iscontact || requestContactSent || requestContactReceived" [priority]="100" [content]="'addon.messages.addtoyourcontacts' | translate" (action)="createContactRequest()"></core-context-menu-item>
<core-context-menu-item [hidden]="!otherMember || !otherMember.iscontact" [priority]="100" [content]="'addon.messages.removefromyourcontacts' | translate" (action)="removeContact()"></core-context-menu-item>
<core-context-menu-item [hidden]="!showInfo || isGroup" [priority]="1000" [content]="'addon.messages.info' | translate" (action)="viewInfo()" iconAction="information-circle"></core-context-menu-item>
<core-context-menu-item [hidden]="!showInfo || !isGroup" [priority]="1000" [content]="'addon.messages.groupinfo' | translate" (action)="viewInfo()" iconAction="information-circle"></core-context-menu-item>
<core-context-menu-item [hidden]="!groupMessagingEnabled || !conversation" [priority]="800" [content]="(conversation && conversation.isfavourite ? 'addon.messages.removefromfavourites' : 'addon.messages.addtofavourites') | translate" (action)="changeFavourite($event)" [closeOnClick]="false" [iconAction]="favouriteIcon"></core-context-menu-item>
<core-context-menu-item [hidden]="!otherMember || otherMember.isblocked" [priority]="700" [content]="'addon.messages.blockuser' | translate" (action)="blockUser()" [iconAction]="blockIcon"></core-context-menu-item>
<core-context-menu-item [hidden]="!otherMember || !otherMember.isblocked" [priority]="700" [content]="'addon.messages.unblockuser' | translate" (action)="unblockUser()" [iconAction]="blockIcon"></core-context-menu-item>
<core-context-menu-item [hidden]="!canDelete" [priority]="400" [content]="'addon.messages.showdeletemessages' | translate" (action)="toggleDelete()" [iconAction]="(showDelete ? 'checkbox-outline' : 'square-outline')"></core-context-menu-item>
<core-context-menu-item [hidden]="!groupMessagingEnabled || !conversationId || isGroup" [priority]="200" [content]="'addon.messages.deleteconversation' | translate" (action)="deleteConversation($event)" [closeOnClick]="false" [iconAction]="deleteIcon"></core-context-menu-item>
<core-context-menu-item [hidden]="!otherMember || otherMember.iscontact || requestContactSent || requestContactReceived" [priority]="100" [content]="'addon.messages.addtoyourcontacts' | translate" (action)="createContactRequest()" [iconAction]="addRemoveIcon"></core-context-menu-item>
<core-context-menu-item [hidden]="!otherMember || !otherMember.iscontact" [priority]="100" [content]="'addon.messages.removefromyourcontacts' | translate" (action)="removeContact()" [iconAction]="addRemoveIcon"></core-context-menu-item>
</core-context-menu>
</core-navbar-buttons>
</ion-header>

View File

@ -42,7 +42,7 @@ import * as moment from 'moment';
export class AddonMessagesDiscussionPage implements OnDestroy {
@ViewChild(Content) content: Content;
protected siteId: string;
siteId: string;
protected fetching: boolean;
protected polling;
protected logger;
@ -79,6 +79,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
members: any = {}; // Members that wrote a message, indexed by ID.
favouriteIcon = 'fa-star';
deleteIcon = 'trash';
blockIcon = 'close-circle';
addRemoveIcon = 'add';
otherMember: any; // Other member information (individual conversations only).
footerType: 'message' | 'blocked' | 'requiresContact' | 'requestSent' | 'requestReceived' | 'unable';
requestContactSent = false;
@ -420,6 +422,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
this.favouriteIcon = conversation.isfavourite ? 'fa-star-o' : 'fa-star';
if (!this.isGroup) {
this.userId = conversation.userid;
this.blockIcon = this.otherMember && this.otherMember.isblocked ? 'close-circle' : 'checkmark-circle';
this.addRemoveIcon = this.otherMember && this.otherMember.iscontact ? 'remove' : 'add';
}
return true;
@ -1086,6 +1090,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
const okText = this.translate.instant('addon.messages.blockuser');
return this.domUtils.showConfirm(template, undefined, okText).then(() => {
this.blockIcon = 'spinner';
const modal = this.domUtils.showModalLoading('core.sending', true);
this.showLoadingModal = true;
@ -1095,6 +1101,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
});
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.error', true);
}).finally(() => {
this.blockIcon = this.otherMember.isblocked ? 'close-circle' : 'checkmark-circle';
});
}
@ -1140,6 +1148,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
const okText = this.translate.instant('addon.messages.unblockuser');
return this.domUtils.showConfirm(template, undefined, okText).then(() => {
this.blockIcon = 'spinner';
const modal = this.domUtils.showModalLoading('core.sending', true);
this.showLoadingModal = true;
@ -1149,6 +1159,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
});
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.error', true);
}).finally(() => {
this.blockIcon = this.otherMember.isblocked ? 'close-circle' : 'checkmark-circle';
});
}
@ -1167,6 +1179,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
const okText = this.translate.instant('core.add');
return this.domUtils.showConfirm(template, undefined, okText).then(() => {
this.addRemoveIcon = 'spinner';
const modal = this.domUtils.showModalLoading('core.sending', true);
this.showLoadingModal = true;
@ -1176,6 +1190,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
});
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.error', true);
}).finally(() => {
this.addRemoveIcon = this.otherMember.iscontact ? 'remove' : 'add';
});
}
@ -1238,6 +1254,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
const okText = this.translate.instant('core.remove');
return this.domUtils.showConfirm(template, undefined, okText).then(() => {
this.addRemoveIcon = 'spinner';
const modal = this.domUtils.showModalLoading('core.sending', true);
this.showLoadingModal = true;
@ -1247,6 +1265,8 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
});
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.error', true);
}).finally(() => {
this.addRemoveIcon = this.otherMember.iscontact ? 'remove' : 'add';
});
}

View File

@ -1,6 +1,10 @@
ion-app.app-root.ios {
.button-ios {
min-height: $button-ios-height
min-height: $button-ios-height;
}
ion-searchbar.searchbar-ios .button-ios {
min-height: auto;
}
// Light buttons color.

View File

@ -554,7 +554,8 @@ ion-app.app-root {
}
}
.toolbar .core-bar-button-image {
.toolbar img.core-bar-button-image,
.toolbar .core-bar-button-image img {
padding: 0;
width: 100%;
height: 100%;

View File

@ -1083,7 +1083,7 @@ export class CoreCourseHelperProvider {
}
const sectionWithModules = sections.find((section) => {
return section.modules.length > 0;
return section.modules && section.modules.length > 0;
});
if (!sectionWithModules || typeof sectionWithModules.modules[0].completion == 'undefined') {
promises.push(this.courseProvider.getActivitiesCompletionStatus(course.id));