diff --git a/src/core/user/lang/en.json b/src/core/user/lang/en.json index d04f99898..861570f59 100644 --- a/src/core/user/lang/en.json +++ b/src/core/user/lang/en.json @@ -1,11 +1,21 @@ { + "address": "Address", + "city": "City/town", + "contact": "Contact", + "country": "Country", + "description": "Description", "details": "Details", "detailsnotavailable": "The details of this user are not available to you.", "editingteacher": "Teacher", + "email": "Email address", "errorloaduser": "Error loading user.", + "interests": "Interests", "manager": "Manager", "newpicture": "New picture", + "phone1": "Phone", + "phone2": "Mobile phone", "roles": "Roles", "student": "Student", - "teacher": "Non-editing teacher" + "teacher": "Non-editing teacher", + "webpage": "Web page" } \ No newline at end of file diff --git a/src/core/user/pages/about/about.html b/src/core/user/pages/about/about.html new file mode 100644 index 000000000..6556144a4 --- /dev/null +++ b/src/core/user/pages/about/about.html @@ -0,0 +1,71 @@ + + + + + + + + + + +
+ + {{ 'core.user.contact' | translate}} + +

{{ 'core.user.email' | translate }}

+

+ +

+
+ +

{{ 'core.user.phone1' | translate}}

+

+ +

+
+ +

{{ 'core.user.phone2' | translate}}

+

+ +

+
+ +

{{ 'core.user.address' | translate}}

+

+ + + + +

+
+ +

{{ 'core.user.city' | translate}}

+

+
+ +

{{ 'core.user.country' | translate}}

+

+
+
+ + {{ 'core.userdetails' | translate}} + +

{{ 'core.user.webpage' | translate}}

+

+ +

+
+ +

{{ 'core.user.interests' | translate}}

+

+
+
+ + {{ 'core.user.description' | translate}} + +

+
+
+
+ +
\ No newline at end of file diff --git a/src/core/user/pages/about/about.module.ts b/src/core/user/pages/about/about.module.ts new file mode 100644 index 000000000..07f43dbba --- /dev/null +++ b/src/core/user/pages/about/about.module.ts @@ -0,0 +1,33 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreUserAboutPage } from './about'; +import { CoreDirectivesModule } from '../../../../directives/directives.module'; +import { CoreComponentsModule } from '../../../../components/components.module'; + +@NgModule({ + declarations: [ + CoreUserAboutPage, + ], + imports: [ + CoreComponentsModule, + CoreDirectivesModule, + IonicPageModule.forChild(CoreUserAboutPage), + TranslateModule.forChild() + ], +}) +export class CoreUserAboutPageModule {} diff --git a/src/core/user/pages/about/about.scss b/src/core/user/pages/about/about.scss new file mode 100644 index 000000000..1752c93e5 --- /dev/null +++ b/src/core/user/pages/about/about.scss @@ -0,0 +1,2 @@ +page-core-user-about { +} \ No newline at end of file diff --git a/src/core/user/pages/about/about.ts b/src/core/user/pages/about/about.ts new file mode 100644 index 000000000..603e8e43b --- /dev/null +++ b/src/core/user/pages/about/about.ts @@ -0,0 +1,100 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Component } from '@angular/core'; +import { IonicPage, NavParams, Platform } from 'ionic-angular'; +import { CoreUserProvider } from '../../providers/user'; +import { CoreUserHelperProvider } from '../../providers/helper'; +import { CoreDomUtilsProvider } from '../../../../providers/utils/dom'; +import { CoreCoursesProvider } from '../../../courses/providers/courses'; +import { CoreEventsProvider } from '../../../../providers/events'; +import { CoreSitesProvider } from '../../../../providers/sites'; + +/** + * Page that displays an user about page. + */ +@IonicPage({segment: "core-user-about"}) +@Component({ + selector: 'page-core-user-about', + templateUrl: 'about.html', +}) +export class CoreUserAboutPage { + protected courseId: number; + protected userId: number; + protected siteId; + + userLoaded: boolean = false; + hasContact: boolean = false; + hasDetails: boolean = false; + isAndroid: boolean = false; + user: any = {}; + title: string; + + constructor(private navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider, + private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider, + private sitesProvider: CoreSitesProvider, private platform: Platform) { + + this.userId = navParams.get('userId'); + this.courseId = navParams.get('courseId'); + this.isAndroid = this.platform.is('android'); + + this.siteId = this.sitesProvider.getCurrentSite().getId(); + } + + /** + * View loaded. + */ + ionViewDidLoad() { + this.fetchUser().finally(() => { + this.userLoaded = true; + }); + } + + /** + * Fetches the user and updates the view. + */ + fetchUser() : Promise { + return this.userProvider.getProfile(this.userId, this.courseId).then((user) => { + + if (user.address) { + user.address = this.userHelper.formatAddress(user.address, user.city, user.country); + user.encodedAddress = encodeURIComponent(user.address); + } + + this.hasContact = user.email || user.phone1 || user.phone2 || user.city || user.country || user.address; + this.hasDetails = user.url || user.interests || (user.customfields && user.customfields.length > 0); + + this.user = user; + this.title = user.fullname; + }).catch((error) => { + this.domUtils.showErrorModalDefault(error, 'core.user.errorloaduser', true); + }); + } + + /** + * Refresh the user. + * + * @param {any} refresher Refresher. + */ + refreshUser(refresher?: any) { + this.userProvider.invalidateUserCache(this.userId).finally(() => { + this.fetchUser().finally(() => { + this.eventsProvider.trigger(CoreUserProvider.PROFILE_REFRESHED, {courseId: this.courseId, userId: this.userId, + user: this.user}, this.siteId); + refresher && refresher.complete(); + }); + }); + } + +} \ No newline at end of file diff --git a/src/core/user/pages/profile/profile.html b/src/core/user/pages/profile/profile.html index 2aec9846a..d730e1182 100644 --- a/src/core/user/pages/profile/profile.html +++ b/src/core/user/pages/profile/profile.html @@ -23,7 +23,7 @@

-