MOBILE-2430 data: Click on image action fixed

main
Pau Ferrer Ocaña 2018-06-21 15:56:02 +02:00
parent d97fdcee93
commit 83e41ba1a1
6 changed files with 15 additions and 11 deletions

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Input, OnInit, OnChanges, SimpleChange } from '@angular/core'; import { Input, Output, OnInit, OnChanges, SimpleChange, EventEmitter } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
/** /**
@ -23,11 +23,13 @@ export class AddonModDataFieldPluginComponent implements OnInit, OnChanges {
@Input() value?: any; // The value of the field. @Input() value?: any; // The value of the field.
@Input() database?: any; // Database object. @Input() database?: any; // Database object.
@Input() error?: string; // Error when editing. @Input() error?: string; // Error when editing.
@Input() viewAction?: string; // Action to perform. @Output() gotoEntry?: EventEmitter<number>; // Action to perform.
@Input() form?: FormGroup; // Form where to add the form control. Just required for edit and search modes. @Input() form?: FormGroup; // Form where to add the form control. Just required for edit and search modes.
@Input() search?: any; // The search value of all fields. @Input() search?: any; // The search value of all fields.
constructor(protected fb: FormBuilder) { } constructor(protected fb: FormBuilder) {
this.gotoEntry = new EventEmitter();
}
/** /**
* Add the form control for the search mode. * Add the form control for the search mode.

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, Input, OnInit, Injector, ViewChild, OnChanges, SimpleChange } from '@angular/core'; import { Component, Input, Output, OnInit, Injector, ViewChild, OnChanges, SimpleChange, EventEmitter } from '@angular/core';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { AddonModDataProvider } from '../../providers/data'; import { AddonModDataProvider } from '../../providers/data';
import { AddonModDataFieldsDelegate } from '../../providers/fields-delegate'; import { AddonModDataFieldsDelegate } from '../../providers/fields-delegate';
@ -32,7 +32,7 @@ export class AddonModDataFieldPluginComponent implements OnInit, OnChanges {
@Input() value?: any; // The value of the field. @Input() value?: any; // The value of the field.
@Input() database?: any; // Database object. @Input() database?: any; // Database object.
@Input() error?: string; // Error when editing. @Input() error?: string; // Error when editing.
@Input() viewAction: string; // Action to perform. @Output() gotoEntry: EventEmitter<number>; // Action to perform.
@Input() form?: FormGroup; // Form where to add the form control. Just required for edit and search modes. @Input() form?: FormGroup; // Form where to add the form control. Just required for edit and search modes.
@Input() search?: any; // The search value of all fields. @Input() search?: any; // The search value of all fields.
@ -42,6 +42,7 @@ export class AddonModDataFieldPluginComponent implements OnInit, OnChanges {
constructor(protected injector: Injector, protected dataDelegate: AddonModDataFieldsDelegate, constructor(protected injector: Injector, protected dataDelegate: AddonModDataFieldsDelegate,
protected dataProvider: AddonModDataProvider) { protected dataProvider: AddonModDataProvider) {
this.gotoEntry = new EventEmitter();
} }
/** /**
@ -66,7 +67,7 @@ export class AddonModDataFieldPluginComponent implements OnInit, OnChanges {
value: this.value, value: this.value,
database: this.database, database: this.database,
error: this.error, error: this.error,
viewAction: this.viewAction, gotoEntry: this.gotoEntry,
form: this.form, form: this.form,
search: this.search search: this.search
}; };

View File

@ -329,7 +329,8 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
this.jsData = { this.jsData = {
fields: this.fields, fields: this.fields,
entries: this.entries, entries: this.entries,
data: this.data data: this.data,
gotoEntry: this.gotoEntry.bind(this)
}; };
}); });
} else if (!this.search.searching) { } else if (!this.search.searching) {

View File

@ -11,6 +11,6 @@
<ion-input type="text" [formControlName]="'f_'+field.id" [placeholder]="field.name"></ion-input> <ion-input type="text" [formControlName]="'f_'+field.id" [placeholder]="field.name"></ion-input>
</span> </span>
<span *ngIf="mode == 'list' && imageUrl" (click)="viewAction()"><img [src]="imageUrl" [alt]="title" [title]="title" class="core-media-adapt-width list_picture" core-external-content/></span> <span *ngIf="mode == 'list' && imageUrl" (click)="gotoEntry.emit(entryId)"><img [src]="imageUrl" [alt]="title" [title]="title" class="core-media-adapt-width list_picture" core-external-content/></span>
<img *ngIf="mode == 'show' && imageUrl" [src]="imageUrl" [alt]="title" [title]="title" class="core-media-adapt-width list_picture" [width]="width" [height]="height" core-external-content/> <img *ngIf="mode == 'show' && imageUrl" [src]="imageUrl" [alt]="title" [title]="title" class="core-media-adapt-width list_picture" [width]="width" [height]="height" core-external-content/>

View File

@ -2,8 +2,8 @@
<ion-navbar> <ion-navbar>
<ion-title><core-format-text [text]="title"></core-format-text></ion-title> <ion-title><core-format-text [text]="title"></core-format-text></ion-title>
<ion-buttons end> <ion-buttons end>
<button ion-button icon-only (click)="save()" [attr.aria-label]="'core.save' | translate"> <button ion-button clear (click)="save()" [attr.aria-label]="'core.save' | translate">
<ion-icon name="send"></ion-icon> {{ 'core.save' | translate }}
</button> </button>
</ion-buttons> </ion-buttons>
</ion-navbar> </ion-navbar>

View File

@ -119,7 +119,7 @@ export class AddonModDataHelperProvider {
// Replace field by a generic directive. // Replace field by a generic directive.
render = '<addon-mod-data-field-plugin [field]="fields[' + field.id + ']" [value]="entries[' + entry.id + render = '<addon-mod-data-field-plugin [field]="fields[' + field.id + ']" [value]="entries[' + entry.id +
'].contents[' + field.id + ']" mode="' + mode + '" [database]="data" (viewAction)="gotoEntry(' + entry.id + '].contents[' + field.id + ']" mode="' + mode + '" [database]="data" (gotoEntry)="gotoEntry(' + entry.id +
')"></addon-mod-data-field-plugin>'; ')"></addon-mod-data-field-plugin>';
template = template.replace(replace, render); template = template.replace(replace, render);
}); });