Merge pull request #1541 from dpalou/MOBILE-2601
MOBILE-2601 calendar: Display location in calendar eventsmain
commit
e26d2b0a04
|
@ -9,7 +9,7 @@
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<core-loading [hideUntil]="eventLoaded">
|
<core-loading [hideUntil]="eventLoaded">
|
||||||
<ion-card>
|
<ion-card>
|
||||||
<ion-card-content>
|
<ion-card-content *ngIf="event">
|
||||||
<ion-card-title text-wrap>
|
<ion-card-title text-wrap>
|
||||||
<core-icon *ngIf="event.icon && !event.moduleIcon" [name]="event.icon" item-start></core-icon>
|
<core-icon *ngIf="event.icon && !event.moduleIcon" [name]="event.icon" item-start></core-icon>
|
||||||
<core-format-text [text]="event.name"></core-format-text>
|
<core-format-text [text]="event.name"></core-format-text>
|
||||||
|
@ -33,11 +33,19 @@
|
||||||
<ion-item text-wrap *ngIf="event.moduleIcon">
|
<ion-item text-wrap *ngIf="event.moduleIcon">
|
||||||
<img *ngIf="event.moduleIcon" src="{{event.moduleIcon}}" item-start alt="" role="presentation" class="core-module-icon"> {{event.moduleName}}
|
<img *ngIf="event.moduleIcon" src="{{event.moduleIcon}}" item-start alt="" role="presentation" class="core-module-icon"> {{event.moduleName}}
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item>
|
<ion-item text-wrap *ngIf="event.description">
|
||||||
<p text-wrap *ngIf="event.description">
|
<p>
|
||||||
<core-format-text [text]="event.description"></core-format-text>
|
<core-format-text [text]="event.description"></core-format-text>
|
||||||
</p>
|
</p>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
<ion-item text-wrap *ngIf="event.location">
|
||||||
|
<h2>{{ 'core.location' | translate}}</h2>
|
||||||
|
<p>
|
||||||
|
<a [href]="event.encodedLocation" core-link auto-login="no">
|
||||||
|
<core-format-text [text]="event.location"></core-format-text>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</ion-item>
|
||||||
<ion-item *ngIf="moduleUrl">
|
<ion-item *ngIf="moduleUrl">
|
||||||
<a ion-button block color="primary" [href]="moduleUrl" core-link capture="true">{{ 'addon.calendar.gotoactivity' | translate }}</a>
|
<a ion-button block color="primary" [href]="moduleUrl" core-link capture="true">{{ 'addon.calendar.gotoactivity' | translate }}</a>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
|
@ -166,6 +166,12 @@ export class AddonCalendarEventPage {
|
||||||
this.categoryPath = event.category.nestedname;
|
this.categoryPath = event.category.nestedname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.location) {
|
||||||
|
// Build a link to open the address in maps.
|
||||||
|
event.location = this.textUtils.decodeHTML(event.location);
|
||||||
|
event.encodedLocation = this.textUtils.buildAddressURL(event.location);
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.domUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevent', true);
|
this.domUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevent', true);
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { IonicPage, NavParams } from 'ionic-angular';
|
||||||
import { IonicPage, NavParams, Platform } from 'ionic-angular';
|
|
||||||
import { CoreUserProvider } from '../../providers/user';
|
import { CoreUserProvider } from '../../providers/user';
|
||||||
import { CoreUserHelperProvider } from '../../providers/helper';
|
import { CoreUserHelperProvider } from '../../providers/helper';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
|
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays an user about page.
|
* Page that displays an user about page.
|
||||||
|
@ -37,17 +37,15 @@ export class CoreUserAboutPage {
|
||||||
userLoaded = false;
|
userLoaded = false;
|
||||||
hasContact = false;
|
hasContact = false;
|
||||||
hasDetails = false;
|
hasDetails = false;
|
||||||
isAndroid = false;
|
|
||||||
user: any = {};
|
user: any = {};
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
constructor(navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider,
|
constructor(navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider,
|
||||||
private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider, private sanitizer: DomSanitizer,
|
private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider,
|
||||||
private sitesProvider: CoreSitesProvider, private platform: Platform) {
|
private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider) {
|
||||||
|
|
||||||
this.userId = navParams.get('userId');
|
this.userId = navParams.get('userId');
|
||||||
this.courseId = navParams.get('courseId');
|
this.courseId = navParams.get('courseId');
|
||||||
this.isAndroid = this.platform.is('android');
|
|
||||||
|
|
||||||
this.siteId = this.sitesProvider.getCurrentSite().getId();
|
this.siteId = this.sitesProvider.getCurrentSite().getId();
|
||||||
}
|
}
|
||||||
|
@ -69,8 +67,7 @@ export class CoreUserAboutPage {
|
||||||
|
|
||||||
if (user.address) {
|
if (user.address) {
|
||||||
user.address = this.userHelper.formatAddress(user.address, user.city, user.country);
|
user.address = this.userHelper.formatAddress(user.address, user.city, user.country);
|
||||||
user.encodedAddress = this.sanitizer.bypassSecurityTrustUrl(
|
user.encodedAddress = this.textUtils.buildAddressURL(user.address);
|
||||||
(this.isAndroid ? 'geo:0,0?q=' : 'http://maps.google.com?q=') + encodeURIComponent(user.address));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hasContact = user.email || user.phone1 || user.phone2 || user.city || user.country || user.address;
|
this.hasContact = user.email || user.phone1 || user.phone2 || user.city || user.country || user.address;
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
"listsep": ",",
|
"listsep": ",",
|
||||||
"loading": "Loading",
|
"loading": "Loading",
|
||||||
"loadmore": "Load more",
|
"loadmore": "Load more",
|
||||||
|
"location": "Location",
|
||||||
"lostconnection": "Your authentication token is invalid or has expired, you will have to reconnect to the site.",
|
"lostconnection": "Your authentication token is invalid or has expired, you will have to reconnect to the site.",
|
||||||
"maxsizeandattachments": "Maximum size for new files: {{$a.size}}, maximum attachments: {{$a.attachments}}",
|
"maxsizeandattachments": "Maximum size for new files: {{$a.size}}, maximum attachments: {{$a.attachments}}",
|
||||||
"min" : "min",
|
"min" : "min",
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ModalController } from 'ionic-angular';
|
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
||||||
|
import { ModalController, Platform } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreLangProvider } from '../lang';
|
import { CoreLangProvider } from '../lang';
|
||||||
|
|
||||||
|
@ -70,7 +71,19 @@ export class CoreTextUtilsProvider {
|
||||||
|
|
||||||
protected template = document.createElement('template'); // A template element to convert HTML to element.
|
protected template = document.createElement('template'); // A template element to convert HTML to element.
|
||||||
|
|
||||||
constructor(private translate: TranslateService, private langProvider: CoreLangProvider, private modalCtrl: ModalController) { }
|
constructor(private translate: TranslateService, private langProvider: CoreLangProvider, private modalCtrl: ModalController,
|
||||||
|
private sanitizer: DomSanitizer, private platform: Platform) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an address as a string, return a URL to open the address in maps.
|
||||||
|
*
|
||||||
|
* @param {string} address The address.
|
||||||
|
* @return {SafeUrl} URL to view the address.
|
||||||
|
*/
|
||||||
|
buildAddressURL(address: string): SafeUrl {
|
||||||
|
return this.sanitizer.bypassSecurityTrustUrl((this.platform.is('android') ? 'geo:0,0?q=' : 'http://maps.google.com?q=') +
|
||||||
|
encodeURIComponent(address));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a list of sentences, build a message with all of them wrapped in <p>.
|
* Given a list of sentences, build a message with all of them wrapped in <p>.
|
||||||
|
@ -231,7 +244,7 @@ export class CoreTextUtilsProvider {
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
.replace(/>/g, '>')
|
.replace(/>/g, '>')
|
||||||
.replace(/"/g, '"')
|
.replace(/"/g, '"')
|
||||||
.replace(/'/g, '')
|
.replace(/'/g, '\'')
|
||||||
.replace(/ /g, ' ');
|
.replace(/ /g, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue