MOBILE-2201 tag: List component
parent
fa3a2d3140
commit
f5cfda53a5
|
@ -1793,6 +1793,7 @@
|
||||||
"core.submit": "moodle",
|
"core.submit": "moodle",
|
||||||
"core.success": "moodle",
|
"core.success": "moodle",
|
||||||
"core.tablet": "local_moodlemobileapp",
|
"core.tablet": "local_moodlemobileapp",
|
||||||
|
"core.tag.tags": "moodle",
|
||||||
"core.teachers": "moodle",
|
"core.teachers": "moodle",
|
||||||
"core.thereisdatatosync": "local_moodlemobileapp",
|
"core.thereisdatatosync": "local_moodlemobileapp",
|
||||||
"core.thisdirection": "langconfig",
|
"core.thisdirection": "langconfig",
|
||||||
|
|
|
@ -81,6 +81,7 @@ import { CoreQuestionModule } from '@core/question/question.module';
|
||||||
import { CoreCommentsModule } from '@core/comments/comments.module';
|
import { CoreCommentsModule } from '@core/comments/comments.module';
|
||||||
import { CoreBlockModule } from '@core/block/block.module';
|
import { CoreBlockModule } from '@core/block/block.module';
|
||||||
import { CoreRatingModule } from '@core/rating/rating.module';
|
import { CoreRatingModule } from '@core/rating/rating.module';
|
||||||
|
import { CoreTagModule } from '@core/tag/tag.module';
|
||||||
|
|
||||||
// Addon modules.
|
// Addon modules.
|
||||||
import { AddonBadgesModule } from '@addon/badges/badges.module';
|
import { AddonBadgesModule } from '@addon/badges/badges.module';
|
||||||
|
@ -223,6 +224,7 @@ export const CORE_PROVIDERS: any[] = [
|
||||||
CoreBlockModule,
|
CoreBlockModule,
|
||||||
CoreRatingModule,
|
CoreRatingModule,
|
||||||
CorePushNotificationsModule,
|
CorePushNotificationsModule,
|
||||||
|
CoreTagModule,
|
||||||
AddonBadgesModule,
|
AddonBadgesModule,
|
||||||
AddonBlogModule,
|
AddonBlogModule,
|
||||||
AddonCalendarModule,
|
AddonCalendarModule,
|
||||||
|
|
|
@ -1793,6 +1793,7 @@
|
||||||
"core.submit": "Submit",
|
"core.submit": "Submit",
|
||||||
"core.success": "Success",
|
"core.success": "Success",
|
||||||
"core.tablet": "Tablet",
|
"core.tablet": "Tablet",
|
||||||
|
"core.tag.tags": "Tags",
|
||||||
"core.teachers": "Teachers",
|
"core.teachers": "Teachers",
|
||||||
"core.thereisdatatosync": "There are offline {{$a}} to be synchronised.",
|
"core.thereisdatatosync": "There are offline {{$a}} to be synchronised.",
|
||||||
"core.thisdirection": "ltr",
|
"core.thisdirection": "ltr",
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
// (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 { CommonModule } from '@angular/common';
|
||||||
|
import { IonicModule } from 'ionic-angular';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { CoreTagListComponent } from './list/list';
|
||||||
|
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
CoreTagListComponent
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
IonicModule,
|
||||||
|
CoreDirectivesModule,
|
||||||
|
TranslateModule.forChild()
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
CoreTagListComponent
|
||||||
|
],
|
||||||
|
entryComponents: [
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class CoreTagComponentsModule {}
|
|
@ -0,0 +1,3 @@
|
||||||
|
<ng-container *ngFor="let tag of tags">
|
||||||
|
<ion-badge (click)="openTag(tag)" class="core-tag-list-tag">{{ tag.rawname }}</ion-badge>
|
||||||
|
</ng-container>
|
|
@ -0,0 +1,7 @@
|
||||||
|
ion-app.app-root core-tag-list {
|
||||||
|
line-height: 1.6;
|
||||||
|
|
||||||
|
ion-badge {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// (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, Input, Optional } from '@angular/core';
|
||||||
|
import { NavController } from 'ionic-angular';
|
||||||
|
import { CoreTagItem } from '@core/tag/providers/tag';
|
||||||
|
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component that displays the list of tags of an item.
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'core-tag-list',
|
||||||
|
templateUrl: 'core-tag-list.html'
|
||||||
|
})
|
||||||
|
export class CoreTagListComponent {
|
||||||
|
@Input() tags: CoreTagItem[];
|
||||||
|
|
||||||
|
constructor(private navCtrl: NavController, @Optional() private svComponent: CoreSplitViewComponent) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to tag index page.
|
||||||
|
*/
|
||||||
|
openTag(tag: CoreTagItem): void {
|
||||||
|
const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl;
|
||||||
|
const params = {
|
||||||
|
tagId: tag.id,
|
||||||
|
tagName: tag.rawname,
|
||||||
|
collectionId: tag.tagcollid,
|
||||||
|
fromContextId: tag.taginstancecontextid
|
||||||
|
};
|
||||||
|
navCtrl.push('CoreTagIndexPage', params);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"tags": "Tags"
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
// (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 { CoreSitesProvider } from '@providers/sites';
|
||||||
|
import { CoreSite } from '@classes/site';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure of a tag item returned by WS.
|
||||||
|
*/
|
||||||
|
export interface CoreTagItem {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
rawname: string;
|
||||||
|
isstandard: boolean;
|
||||||
|
tagcollid: number;
|
||||||
|
taginstanceid: number;
|
||||||
|
taginstancecontextid: number;
|
||||||
|
itemid: number;
|
||||||
|
ordering: number;
|
||||||
|
flag: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service to handle tags.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class CoreTagProvider {
|
||||||
|
|
||||||
|
constructor(private sitesProvider: CoreSitesProvider) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether tags are available in a certain site.
|
||||||
|
*
|
||||||
|
* @param {string} [siteId] Site Id. If not defined, use current site.
|
||||||
|
* @return {Promise<boolean>} Promise resolved with true if available, resolved with false otherwise.
|
||||||
|
* @since 3.7
|
||||||
|
*/
|
||||||
|
areTagsAvailable(siteId?: string): Promise<boolean> {
|
||||||
|
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||||
|
return this.areTagsAvailableInSite(site);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether tags are available in a certain site.
|
||||||
|
*
|
||||||
|
* @param {CoreSite} [site] Site. If not defined, use current site.
|
||||||
|
* @return {boolean} True if available.
|
||||||
|
*/
|
||||||
|
areTagsAvailableInSite(site?: CoreSite): boolean {
|
||||||
|
site = site || this.sitesProvider.getCurrentSite();
|
||||||
|
|
||||||
|
return site.wsAvailable('core_tag_get_tagindex_per_area') &&
|
||||||
|
site.wsAvailable('core_tag_get_tag_cloud') &&
|
||||||
|
site.wsAvailable('core_tag_get_tag_collections') &&
|
||||||
|
!site.isFeatureDisabled('NoDelegate_CoreTag');
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 { NgModule } from '@angular/core';
|
||||||
|
import { CoreTagProvider } from './providers/tag';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
CoreTagProvider,
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class CoreTagModule {
|
||||||
|
}
|
Loading…
Reference in New Issue