MOBILE-2317 user: Implement user-link and user module structure
parent
b28294a812
commit
c2946cc797
|
@ -60,6 +60,7 @@ import { CoreSharedFilesModule } from '../core/sharedfiles/sharedfiles.module';
|
|||
import { CoreCourseModule } from '../core/course/course.module';
|
||||
import { CoreSiteHomeModule } from '../core/sitehome/sitehome.module';
|
||||
import { CoreContentLinksModule } from '../core/contentlinks/contentlinks.module';
|
||||
import { CoreUserModule } from '../core/user/user.module';
|
||||
|
||||
// Addon modules.
|
||||
import { AddonCalendarModule } from '../addon/calendar/calendar.module';
|
||||
|
@ -97,6 +98,7 @@ export function createTranslateLoader(http: HttpClient) {
|
|||
CoreCourseModule,
|
||||
CoreSiteHomeModule,
|
||||
CoreContentLinksModule,
|
||||
CoreUserModule,
|
||||
AddonCalendarModule
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</ion-header>
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<a ion-item core-user-link>
|
||||
<a ion-item core-user-link userId="{{siteInfo.userid}}">
|
||||
<ion-avatar item-start>
|
||||
<img [src]="siteInfo.userpictureurl" core-external-content alt="{{ 'core.pictureof' | translate:{$a: siteInfo.fullname} }}" role="presentation">
|
||||
</ion-avatar>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title><core-format-text [text]="title"></core-format-text></ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
</ion-content>
|
|
@ -0,0 +1,29 @@
|
|||
// (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 { CoreUserProfilePage } from './profile';
|
||||
import { CoreDirectivesModule } from '../../../../directives/directives.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
CoreUserProfilePage,
|
||||
],
|
||||
imports: [
|
||||
CoreDirectivesModule,
|
||||
IonicPageModule.forChild(CoreUserProfilePage),
|
||||
],
|
||||
})
|
||||
export class CoreUserProfilePageModule {}
|
|
@ -0,0 +1,3 @@
|
|||
page-core-user-profile {
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// (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 } from 'ionic-angular';
|
||||
import { CoreUserProvider } from '../../providers/user';
|
||||
|
||||
/**
|
||||
* Page that displays an user profile page.
|
||||
*/
|
||||
@IonicPage({segment: "core-user-profile"})
|
||||
@Component({
|
||||
selector: 'page-core-user-profile',
|
||||
templateUrl: 'profile.html',
|
||||
})
|
||||
export class CoreUserProfilePage {
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
// (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 { Injectable } from '@angular/core';
|
||||
import { CoreLoggerProvider } from '../../../providers/logger';
|
||||
|
||||
/**
|
||||
* Service to interact with plugins to be shown in user profile. Provides functions to register a plugin
|
||||
* and notify an update in the data.
|
||||
*/
|
||||
@Injectable()
|
||||
export class CoreUserDelegate {
|
||||
protected logger;
|
||||
|
||||
constructor(logger: CoreLoggerProvider) {
|
||||
this.logger = logger.getInstance('CoreUserDelegate');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
// (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 { Injectable } from '@angular/core';
|
||||
|
||||
/**
|
||||
* Service to provide user functionalities.
|
||||
*/
|
||||
@Injectable()
|
||||
export class CoreUserProvider {
|
||||
|
||||
constructor() {}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// (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 { CoreUserDelegate } from './providers/delegate';
|
||||
import { CoreUserProvider } from './providers/user';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
],
|
||||
imports: [
|
||||
],
|
||||
providers: [
|
||||
CoreUserDelegate,
|
||||
CoreUserProvider
|
||||
]
|
||||
})
|
||||
export class CoreUserModule {}
|
|
@ -18,6 +18,7 @@ import { CoreExternalContentDirective } from './external-content';
|
|||
import { CoreFormatTextDirective } from './format-text';
|
||||
import { CoreLinkDirective } from './link';
|
||||
import { CoreKeepKeyboardDirective } from './keep-keyboard';
|
||||
import { CoreUserLinkDirective } from './user-link';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@ -25,7 +26,8 @@ import { CoreKeepKeyboardDirective } from './keep-keyboard';
|
|||
CoreExternalContentDirective,
|
||||
CoreFormatTextDirective,
|
||||
CoreKeepKeyboardDirective,
|
||||
CoreLinkDirective
|
||||
CoreLinkDirective,
|
||||
CoreUserLinkDirective
|
||||
],
|
||||
imports: [],
|
||||
exports: [
|
||||
|
@ -33,7 +35,8 @@ import { CoreKeepKeyboardDirective } from './keep-keyboard';
|
|||
CoreExternalContentDirective,
|
||||
CoreFormatTextDirective,
|
||||
CoreKeepKeyboardDirective,
|
||||
CoreLinkDirective
|
||||
CoreLinkDirective,
|
||||
CoreUserLinkDirective
|
||||
]
|
||||
})
|
||||
export class CoreDirectivesModule {}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
// (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 { Directive, Input, OnInit, ElementRef } from '@angular/core';
|
||||
import { NavController } from 'ionic-angular';
|
||||
/**
|
||||
* Directive to open a link in external browser.
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[core-user-link]'
|
||||
})
|
||||
export class CoreUserLinkDirective implements OnInit {
|
||||
@Input() userId: number; // User id to open the profile.
|
||||
@Input() courseId?: number; // If set, course id to show the user info related to that course.
|
||||
|
||||
protected element: HTMLElement;
|
||||
|
||||
constructor(element: ElementRef, private navCtrl: NavController) {
|
||||
// This directive can be added dynamically. In that case, the first param is the anchor HTMLElement.
|
||||
this.element = element.nativeElement || element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function executed when the component is initialized.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.element.addEventListener('click', (event) => {
|
||||
// If the event prevented default action, do nothing.
|
||||
if (!event.defaultPrevented) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.navCtrl.push('CoreUserProfilePage', {userId: this.userId, courseId: this.courseId});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue