MOBILE-2267 forum: Add open in browser link to posts
parent
470abc056b
commit
6219947374
|
@ -114,7 +114,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
|
||||||
this.filter.courseId = navParams.get('courseId');
|
this.filter.courseId = navParams.get('courseId');
|
||||||
this.filter.categoryId = navParams.get('categoryId');
|
this.filter.categoryId = navParams.get('categoryId');
|
||||||
|
|
||||||
this.filter.filtered = this.filter.courseId || AddonCalendarProvider.ALL_TYPES.some((name) => !this.filter[name]);
|
this.filter.filtered = !!this.filter.courseId || AddonCalendarProvider.ALL_TYPES.some((name) => !this.filter[name]);
|
||||||
|
|
||||||
this.year = navParams.get('year') || now.getFullYear();
|
this.year = navParams.get('year') || now.getFullYear();
|
||||||
this.month = navParams.get('month') || (now.getMonth() + 1);
|
this.month = navParams.get('month') || (now.getMonth() + 1);
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<ion-item text-wrap (click)="dismiss()" *ngIf="wordCount">
|
<ion-item text-wrap (click)="dismiss()" *ngIf="wordCount">
|
||||||
<h2>{{ 'core.numwords' | translate: {'$a': wordCount} }}</h2>
|
<h2>{{ 'core.numwords' | translate: {'$a': wordCount} }}</h2>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item text-wrap (click)="dismiss()" *ngIf="!canEdit && !canDelete && !wordCount">
|
<a ion-item text-wrap [href]="url" *ngIf="url" core-link capture="false">
|
||||||
<h2>{{ 'core.nooptionavailable' | translate }}</h2>
|
<ion-icon name="open" item-start></ion-icon>
|
||||||
</ion-item>
|
<h2>{{ 'core.openinbrowser' | translate }}</h2>
|
||||||
|
</a>
|
||||||
</core-loading>
|
</core-loading>
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { NavParams, ViewController } from 'ionic-angular';
|
import { NavParams, ViewController } from 'ionic-angular';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
|
import { CoreSite } from '@classes/site';
|
||||||
import { AddonModForumProvider } from '../../providers/forum';
|
import { AddonModForumProvider } from '../../providers/forum';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,11 +33,13 @@ export class AddonForumPostOptionsMenuComponent implements OnInit {
|
||||||
canEdit = false;
|
canEdit = false;
|
||||||
canDelete = false;
|
canDelete = false;
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
url: string;
|
||||||
|
|
||||||
constructor(navParams: NavParams,
|
constructor(navParams: NavParams,
|
||||||
protected viewCtrl: ViewController,
|
protected viewCtrl: ViewController,
|
||||||
protected domUtils: CoreDomUtilsProvider,
|
protected domUtils: CoreDomUtilsProvider,
|
||||||
protected forumProvider: AddonModForumProvider) {
|
protected forumProvider: AddonModForumProvider,
|
||||||
|
protected sitesProvider: CoreSitesProvider) {
|
||||||
this.post = navParams.get('post');
|
this.post = navParams.get('post');
|
||||||
this.forumId = navParams.get('forumId');
|
this.forumId = navParams.get('forumId');
|
||||||
}
|
}
|
||||||
|
@ -46,6 +50,9 @@ export class AddonForumPostOptionsMenuComponent implements OnInit {
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.forumId) {
|
if (this.forumId) {
|
||||||
if (this.post.id) {
|
if (this.post.id) {
|
||||||
|
const site: CoreSite = this.sitesProvider.getCurrentSite();
|
||||||
|
this.url = site.createSiteUrl('/mod/forum/discuss.php', {d: this.post.discussion}, 'p' + this.post.id);
|
||||||
|
|
||||||
this.forumProvider.getDiscussionPost(this.forumId, this.post.discussion, this.post.id, true).then((post) => {
|
this.forumProvider.getDiscussionPost(this.forumId, this.post.discussion, this.post.id, true).then((post) => {
|
||||||
this.canDelete = post.capabilities.delete && this.forumProvider.isDeletePostAvailable();
|
this.canDelete = post.capabilities.delete && this.forumProvider.isDeletePostAvailable();
|
||||||
this.canEdit = post.capabilities.edit && this.forumProvider.isUpdatePostAvailable();
|
this.canEdit = post.capabilities.edit && this.forumProvider.isUpdatePostAvailable();
|
||||||
|
|
|
@ -417,9 +417,9 @@ export class AddonModForumProvider {
|
||||||
return site.read('mod_forum_get_discussion_post', params, preSets).then((response) => {
|
return site.read('mod_forum_get_discussion_post', params, preSets).then((response) => {
|
||||||
if (response.post) {
|
if (response.post) {
|
||||||
return response.post;
|
return response.post;
|
||||||
} else {
|
|
||||||
return Promise.reject(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.reject(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1309,6 +1309,18 @@ export class CoreSite {
|
||||||
return this.urlUtils.getDocsUrl(release, page);
|
return this.urlUtils.getDocsUrl(release, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a url to link an specific page on the site.
|
||||||
|
*
|
||||||
|
* @param path Path of the url to go to.
|
||||||
|
* @param params Object with the params to add.
|
||||||
|
* @param anchor Anchor text if needed.
|
||||||
|
* @return URL with params.
|
||||||
|
*/
|
||||||
|
createSiteUrl(path: string, params?: {[key: string]: any}, anchor?: string): string {
|
||||||
|
return this.urlUtils.addParamsToUrl(this.siteUrl + path, params, anchor);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the local_mobile plugin is installed in the Moodle site.
|
* Check if the local_mobile plugin is installed in the Moodle site.
|
||||||
*
|
*
|
||||||
|
|
|
@ -49,9 +49,10 @@ export class CoreUrlUtilsProvider {
|
||||||
*
|
*
|
||||||
* @param url URL to add the params to.
|
* @param url URL to add the params to.
|
||||||
* @param params Object with the params to add.
|
* @param params Object with the params to add.
|
||||||
|
* @param anchor Anchor text if needed.
|
||||||
* @return URL with params.
|
* @return URL with params.
|
||||||
*/
|
*/
|
||||||
addParamsToUrl(url: string, params: {[key: string]: any}): string {
|
addParamsToUrl(url: string, params?: {[key: string]: any}, anchor?: string): string {
|
||||||
let separator = url.indexOf('?') != -1 ? '&' : '?';
|
let separator = url.indexOf('?') != -1 ? '&' : '?';
|
||||||
|
|
||||||
for (const key in params) {
|
for (const key in params) {
|
||||||
|
@ -64,6 +65,10 @@ export class CoreUrlUtilsProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (anchor) {
|
||||||
|
url += '#' + anchor;
|
||||||
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue