From 82d3bcb0122486451d72383973f09db1551b9d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 21 Jun 2018 12:29:47 +0200 Subject: [PATCH 1/5] MOBILE-2430 mainmenu: Graduation cap icon fix --- src/core/mainmenu/pages/menu/menu.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/mainmenu/pages/menu/menu.scss b/src/core/mainmenu/pages/menu/menu.scss index 8236dbf94..4bca19269 100644 --- a/src/core/mainmenu/pages/menu/menu.scss +++ b/src/core/mainmenu/pages/menu/menu.scss @@ -7,4 +7,10 @@ page-core-mainmenu { @extend .fa-graduation-cap; @extend .fa; } + + .ion-ios-fa-graduation-cap-outline { + color: transparent; + -webkit-text-stroke-width: 0.8px; + -webkit-text-stroke-color: $tabs-tab-color-inactive; + } } From d97fdcee93a4cf1b250dc16e614ff706ecc225c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 21 Jun 2018 12:10:32 +0200 Subject: [PATCH 2/5] MOBILE-2430 rte: Resize with keyboard open and close --- .../rich-text-editor/rich-text-editor.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/components/rich-text-editor/rich-text-editor.ts b/src/components/rich-text-editor/rich-text-editor.ts index bd0feb256..fe2aaef96 100644 --- a/src/components/rich-text-editor/rich-text-editor.ts +++ b/src/components/rich-text-editor/rich-text-editor.ts @@ -46,6 +46,7 @@ import { Subscription } from 'rxjs'; export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy { // Based on: https://github.com/judgewest2000/Ionic3RichText/ // @todo: Anchor button, fullscreen... + // @todo: Textarea height is not being updated when editor is resized. Height is calculated if any css is changed. @Input() placeholder = ''; // Placeholder to set in textarea. @Input() control: FormControl; // Form control. @@ -154,14 +155,21 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy */ protected maximizeEditorSize(): Promise { this.content.resize(); + const contentVisibleHeight = this.content.contentHeight; const deferred = this.utils.promiseDefer(); setTimeout(() => { const contentVisibleHeight = this.content.contentHeight; - // Editor is ready, adjust Height if needed. - if (contentVisibleHeight > 0) { + if (contentVisibleHeight <= 0) { + deferred.resolve(0); + + return; + } + + setTimeout(() => { + // Editor is ready, adjust Height if needed. const height = this.getSurroundingHeight(this.element); if (contentVisibleHeight > height) { this.element.style.height = this.domUtils.formatPixelsSize(contentVisibleHeight - height); @@ -170,11 +178,7 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy } deferred.resolve(contentVisibleHeight - height); - - return; - } - - deferred.resolve(0); + }, 100); }); return deferred.promise; @@ -206,6 +210,13 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy height += this.domUtils.getComputedStyleMeasure(cs, 'paddingTop') + this.domUtils.getComputedStyleMeasure(cs, 'paddingBottom'); + if (element && element.parentNode && element.parentNode.tagName == 'ION-CONTENT') { + const cs2 = getComputedStyle(element); + + height -= this.domUtils.getComputedStyleMeasure(cs2, 'paddingTop') + + this.domUtils.getComputedStyleMeasure(cs2, 'paddingBottom'); + } + return height; } @@ -487,7 +498,6 @@ export class CoreRichTextEditorComponent implements AfterContentInit, OnDestroy */ ngOnDestroy(): void { this.valueChangeSubscription && this.valueChangeSubscription.unsubscribe(); - this.keyboardObs && this.keyboardObs.off(); window.removeEventListener('resize', this.resizeFunction); } } From 83e41ba1a1d71a17dc553a230543921ecfa8bacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 21 Jun 2018 15:56:02 +0200 Subject: [PATCH 3/5] MOBILE-2430 data: Click on image action fixed --- src/addon/mod/data/classes/field-plugin-component.ts | 8 +++++--- .../mod/data/components/field-plugin/field-plugin.ts | 7 ++++--- src/addon/mod/data/components/index/index.ts | 3 ++- .../picture/component/addon-mod-data-field-picture.html | 2 +- src/addon/mod/data/pages/edit/edit.html | 4 ++-- src/addon/mod/data/providers/helper.ts | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/addon/mod/data/classes/field-plugin-component.ts b/src/addon/mod/data/classes/field-plugin-component.ts index 349ac1be7..9265a9ff6 100644 --- a/src/addon/mod/data/classes/field-plugin-component.ts +++ b/src/addon/mod/data/classes/field-plugin-component.ts @@ -11,7 +11,7 @@ // 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 { Input, OnInit, OnChanges, SimpleChange } from '@angular/core'; +import { Input, Output, OnInit, OnChanges, SimpleChange, EventEmitter } from '@angular/core'; 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() database?: any; // Database object. @Input() error?: string; // Error when editing. - @Input() viewAction?: string; // Action to perform. + @Output() gotoEntry?: EventEmitter; // Action to perform. @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. - constructor(protected fb: FormBuilder) { } + constructor(protected fb: FormBuilder) { + this.gotoEntry = new EventEmitter(); + } /** * Add the form control for the search mode. diff --git a/src/addon/mod/data/components/field-plugin/field-plugin.ts b/src/addon/mod/data/components/field-plugin/field-plugin.ts index cf08b715e..fcab3b7dd 100644 --- a/src/addon/mod/data/components/field-plugin/field-plugin.ts +++ b/src/addon/mod/data/components/field-plugin/field-plugin.ts @@ -11,7 +11,7 @@ // 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, 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 { AddonModDataProvider } from '../../providers/data'; 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() database?: any; // Database object. @Input() error?: string; // Error when editing. - @Input() viewAction: string; // Action to perform. + @Output() gotoEntry: EventEmitter; // Action to perform. @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. @@ -42,6 +42,7 @@ export class AddonModDataFieldPluginComponent implements OnInit, OnChanges { constructor(protected injector: Injector, protected dataDelegate: AddonModDataFieldsDelegate, protected dataProvider: AddonModDataProvider) { + this.gotoEntry = new EventEmitter(); } /** @@ -66,7 +67,7 @@ export class AddonModDataFieldPluginComponent implements OnInit, OnChanges { value: this.value, database: this.database, error: this.error, - viewAction: this.viewAction, + gotoEntry: this.gotoEntry, form: this.form, search: this.search }; diff --git a/src/addon/mod/data/components/index/index.ts b/src/addon/mod/data/components/index/index.ts index f7cfca607..8f9e00fa0 100644 --- a/src/addon/mod/data/components/index/index.ts +++ b/src/addon/mod/data/components/index/index.ts @@ -329,7 +329,8 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp this.jsData = { fields: this.fields, entries: this.entries, - data: this.data + data: this.data, + gotoEntry: this.gotoEntry.bind(this) }; }); } else if (!this.search.searching) { diff --git a/src/addon/mod/data/fields/picture/component/addon-mod-data-field-picture.html b/src/addon/mod/data/fields/picture/component/addon-mod-data-field-picture.html index ee6cdcad0..267cc3a08 100644 --- a/src/addon/mod/data/fields/picture/component/addon-mod-data-field-picture.html +++ b/src/addon/mod/data/fields/picture/component/addon-mod-data-field-picture.html @@ -11,6 +11,6 @@ - + diff --git a/src/addon/mod/data/pages/edit/edit.html b/src/addon/mod/data/pages/edit/edit.html index a345aa70c..2c0beac1f 100644 --- a/src/addon/mod/data/pages/edit/edit.html +++ b/src/addon/mod/data/pages/edit/edit.html @@ -2,8 +2,8 @@ - diff --git a/src/addon/mod/data/providers/helper.ts b/src/addon/mod/data/providers/helper.ts index dd152ae51..3a592ccfe 100644 --- a/src/addon/mod/data/providers/helper.ts +++ b/src/addon/mod/data/providers/helper.ts @@ -119,7 +119,7 @@ export class AddonModDataHelperProvider { // Replace field by a generic directive. render = ''; template = template.replace(replace, render); }); From 9f3b03cbde0f67f26d737468f2b1acea8bcefb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 21 Jun 2018 16:18:38 +0200 Subject: [PATCH 4/5] MOBILE-2430 data: Fix size attributes on images --- .../component/addon-mod-data-field-picture.html | 2 +- src/addon/mod/data/fields/picture/component/picture.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/addon/mod/data/fields/picture/component/addon-mod-data-field-picture.html b/src/addon/mod/data/fields/picture/component/addon-mod-data-field-picture.html index 267cc3a08..d0bbb6885 100644 --- a/src/addon/mod/data/fields/picture/component/addon-mod-data-field-picture.html +++ b/src/addon/mod/data/fields/picture/component/addon-mod-data-field-picture.html @@ -13,4 +13,4 @@ - + diff --git a/src/addon/mod/data/fields/picture/component/picture.ts b/src/addon/mod/data/fields/picture/component/picture.ts index a0431b197..dddf848d3 100644 --- a/src/addon/mod/data/fields/picture/component/picture.ts +++ b/src/addon/mod/data/fields/picture/component/picture.ts @@ -13,8 +13,9 @@ // limitations under the License. import { Component } from '@angular/core'; import { FormBuilder } from '@angular/forms'; -import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; import { CoreFileSessionProvider } from '@providers/file-session'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; +import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; import { AddonModDataProvider } from '../../../providers/data'; /** @@ -38,7 +39,8 @@ export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginCo width: string; height: string; - constructor(protected fb: FormBuilder, private fileSessionprovider: CoreFileSessionProvider) { + constructor(protected fb: FormBuilder, private fileSessionprovider: CoreFileSessionProvider, + private domUtils: CoreDomUtilsProvider) { super(fb); } @@ -129,8 +131,8 @@ export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginCo this.imageUrl = (this.image && this.image.fileurl) || null; } } - this.width = this.field.param1 || ''; - this.height = this.field.param2 || ''; + this.width = this.domUtils.formatPixelsSize(this.field.param1); + this.height = this.domUtils.formatPixelsSize(this.field.param2); } } } From 49ae4994810278ec624c07b2d655d8542b2d2a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 21 Jun 2018 17:45:30 +0200 Subject: [PATCH 5/5] MOBILE-2430 data: Fix add entry offline --- .../components/action/addon-mod-data-action.html | 4 ++-- src/addon/mod/data/pages/edit/edit.ts | 14 ++++++++------ src/addon/mod/data/providers/data.ts | 7 ++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/addon/mod/data/components/action/addon-mod-data-action.html b/src/addon/mod/data/components/action/addon-mod-data-action.html index 53f5096d7..5645b0c3c 100644 --- a/src/addon/mod/data/components/action/addon-mod-data-action.html +++ b/src/addon/mod/data/components/action/addon-mod-data-action.html @@ -28,7 +28,7 @@ {{ entry.timemodified * 1000 | coreFormatDate:"dffulldate" }} - + -{{entry.fullname}} +{{entry.fullname}} diff --git a/src/addon/mod/data/pages/edit/edit.ts b/src/addon/mod/data/pages/edit/edit.ts index 55830538f..3220a679d 100644 --- a/src/addon/mod/data/pages/edit/edit.ts +++ b/src/addon/mod/data/pages/edit/edit.ts @@ -253,12 +253,14 @@ export class AddonModDataEditPage { }); } else { this.errors = {}; - result.fieldnotifications.forEach((fieldNotif) => { - const field = this.fieldsArray.find((field) => field.name == fieldNotif.fieldname); - if (field) { - this.errors[field.id] = fieldNotif.notification; - } - }); + if (result.fieldnotifications) { + result.fieldnotifications.forEach((fieldNotif) => { + const field = this.fieldsArray.find((field) => field.name == fieldNotif.fieldname); + if (field) { + this.errors[field.id] = fieldNotif.notification; + } + }); + } this.jsData['errors'] = this.errors; setTimeout(() => { diff --git a/src/addon/mod/data/providers/data.ts b/src/addon/mod/data/providers/data.ts index 4632f2f36..ca9d5da62 100644 --- a/src/addon/mod/data/providers/data.ts +++ b/src/addon/mod/data/providers/data.ts @@ -62,7 +62,7 @@ export class AddonModDataProvider { .then((entry) => { return { // Return provissional entry Id. - newentryid: entry[1] + newentryid: entry }; }); }; @@ -194,8 +194,9 @@ export class AddonModDataProvider { }); // App is offline, check required fields. - fields.forEach((field) => { - const notification = this.fieldsDelegate.getFieldsNotifications(field, contentsIndexed[field.id]); + Object.keys(fields).forEach((key) => { + const field = fields[key], + notification = this.fieldsDelegate.getFieldsNotifications(field, contentsIndexed[field.id]); if (notification) { notifications.push({ fieldname: field.name,