diff --git a/src/addon/mod/data/classes/field-plugin-component.ts b/src/addon/mod/data/classes/field-plugin-component.ts index bcff4da64..512037367 100644 --- a/src/addon/mod/data/classes/field-plugin-component.ts +++ b/src/addon/mod/data/classes/field-plugin-component.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. import { Input } from '@angular/core'; +import { FormGroup, FormBuilder } from '@angular/forms'; /** * Base class for component to render a field. @@ -22,5 +23,29 @@ export class AddonModDataFieldPluginComponent { @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. + @Input() viewAction?: string; // 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) { } + + /** + * Add the form control for the search mode. + * + * @param {string} fieldName Control field name. + * @param {any} value Initial set value. + */ + protected addControl(fieldName: string, value?: any): void { + if (!this.form) { + return; + } + + if (this.mode == 'search') { + this.form.addControl(fieldName, this.fb.control(this.search[fieldName] || null)); + } + + if (this.mode == 'edit') { + this.form.addControl(fieldName, this.fb.control(value || null)); + } + } } 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 0dbf7c501..4e73fafa2 100644 --- a/src/addon/mod/data/components/field-plugin/field-plugin.ts +++ b/src/addon/mod/data/components/field-plugin/field-plugin.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. import { Component, Input, OnInit, Injector, ViewChild } from '@angular/core'; +import { FormGroup } from '@angular/forms'; import { AddonModDataProvider } from '../../providers/data'; import { AddonModDataFieldsDelegate } from '../../providers/fields-delegate'; import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component'; @@ -32,6 +33,8 @@ export class AddonModDataFieldPluginComponent implements OnInit { @Input() database?: any; // Database object. @Input() error?: string; // Error when editing. @Input() viewAction: string; // 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. fieldComponent: any; // Component to render the plugin. data: any; // Data to pass to the component. @@ -63,12 +66,14 @@ export class AddonModDataFieldPluginComponent implements OnInit { value: this.value, database: this.database, error: this.error, - viewAction: this.viewAction + viewAction: this.viewAction, + form: this.form, + search: this.search }; - } else { - this.fieldLoaded = true; } + }).finally(() => { + this.fieldLoaded = true; }); } } diff --git a/src/addon/mod/data/components/index/index.html b/src/addon/mod/data/components/index/index.html index 2fe8fe250..ce67bfa94 100644 --- a/src/addon/mod/data/components/index/index.html +++ b/src/addon/mod/data/components/index/index.html @@ -58,7 +58,7 @@ {{ 'addon.mod_data.resetsettings' | translate}} -
+
diff --git a/src/addon/mod/data/components/index/index.scss b/src/addon/mod/data/components/index/index.scss index 2c2a8e5a3..106a72942 100644 --- a/src/addon/mod/data/components/index/index.scss +++ b/src/addon/mod/data/components/index/index.scss @@ -1,5 +1,5 @@ addon-mod-data-index { - .core-data-contents { + .addon-data-contents { overflow: visible; white-space: normal; word-break: break-word; diff --git a/src/addon/mod/data/components/index/index.ts b/src/addon/mod/data/components/index/index.ts index e2517fc62..fcfae95e3 100644 --- a/src/addon/mod/data/components/index/index.ts +++ b/src/addon/mod/data/components/index/index.ts @@ -13,7 +13,7 @@ // limitations under the License. import { Component, Optional, Injector } from '@angular/core'; -import { Content, ModalController } from 'ionic-angular'; +import { Content, ModalController, NavController } from 'ionic-angular'; import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreGroupsProvider, CoreGroupInfo } from '@providers/groups'; @@ -42,7 +42,6 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp data: any = {}; fields: any; selectedGroup: number; - advancedSearch: any; timeAvailableFrom: number | boolean; timeAvailableFromReadable: string | boolean; timeAvailableTo: number | boolean; @@ -79,7 +78,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp private dataOffline: AddonModDataOfflineProvider, @Optional() @Optional() content: Content, private dataSync: AddonModDataSyncProvider, private timeUtils: CoreTimeUtilsProvider, private groupsProvider: CoreGroupsProvider, private commentsProvider: CoreCommentsProvider, - private modalCtrl: ModalController, private utils: CoreUtilsProvider) { + private modalCtrl: ModalController, private utils: CoreUtilsProvider, protected navCtrl: NavController) { super(injector); // Refresh entries on change. @@ -222,7 +221,6 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp this.fields[field.id] = field; }); this.fieldsArray = this.utils.objectToArray(this.fields); - this.advancedSearch = this.dataHelper.displayAdvancedSearchFields(this.data.asearchtemplate, this.fieldsArray); return this.fetchEntriesData(); }); @@ -349,9 +347,16 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp * Display the chat users modal. */ showSearch(): void { - const modal = this.modalCtrl.create('AddonModDataSearchPage'); + const modal = this.modalCtrl.create('AddonModDataSearchPage', { + search: this.search, + fields: this.fields, + data: this.data}); modal.onDidDismiss((data) => { - // @TODO. + // Add data to search object. + if (data) { + this.search = data; + this.searchEntries(0); + } }); modal.present(); } @@ -366,14 +371,6 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp this.loaded = false; this.search.page = page; - if (this.search.searchingAdvanced) { - this.search.advanced = this.dataHelper.getSearchDataFromForm(document.forms['addon-mod_data-advanced-search-form'], - this.fieldsArray); - this.search.searching = this.search.advanced.length > 0; - } else { - this.search.searching = this.search.text.length > 0; - } - return this.fetchEntriesData().catch((message) => { this.domUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true); }).finally(() => { @@ -405,6 +402,37 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp }); } + /** + * Opens add entries form. + */ + gotoAddEntries(): void { + const stateParams = { + moduleId: this.module.id, + module: this.module, + courseId: this.courseId, + group: this.selectedGroup + }; + + this.navCtrl.push('AddonModDataEditPage', stateParams); + } + + /** + * Goto the selected entry. + * + * @param {number} entryId Entry ID. + */ + gotoEntry(entryId: number): void { + const stateParams = { + module: this.module, + moduleid: this.module.id, + courseid: this.courseId, + entryid: entryId, + group: this.selectedGroup + }; + + this.navCtrl.push('AddonModDataEntryPage', stateParams); + } + /** * Fetch offline entries. * diff --git a/src/addon/mod/data/fields/checkbox/component/checkbox.html b/src/addon/mod/data/fields/checkbox/component/checkbox.html index cc37e6f1e..6bd9c1bd6 100644 --- a/src/addon/mod/data/fields/checkbox/component/checkbox.html +++ b/src/addon/mod/data/fields/checkbox/component/checkbox.html @@ -1,16 +1,17 @@ - + - - {{ option }} - - - - + - + + {{option.key}} + + + + {{ 'addon.mod_data.selectedrequired' | translate }} - + - + + \ No newline at end of file diff --git a/src/addon/mod/data/fields/checkbox/component/checkbox.ts b/src/addon/mod/data/fields/checkbox/component/checkbox.ts index 48404b1a8..37fe87a89 100644 --- a/src/addon/mod/data/fields/checkbox/component/checkbox.ts +++ b/src/addon/mod/data/fields/checkbox/component/checkbox.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -26,13 +24,10 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; - options: number; - values = {}; + options = []; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder) { + super(fb); } /** @@ -45,21 +40,28 @@ export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginC protected render(): void { if (this.mode == 'show') { - this.value.content = this.value.content.split('##').join('
'); + this.value.content = this.value && this.value.content && this.value.content.split('##').join('
'); return; } - this.options = this.field.param1.split('\n'); - - if (this.mode == 'edit' && this.value) { - this.values = {}; + this.options = this.field.param1.split('\n').map((option) => { + return { key: option, value: option }; + }); + if (this.mode == 'edit' && this.value && this.value.content) { this.value.content.split('##').forEach((value) => { - this.values[value] = true; + const x = this.options.findIndex((option) => value == option.key); + if (x >= 0) { + this.options[x].selected = true; + } }); - - //this.control = this.fb.control(text); } + + if (this.mode == 'search') { + this.addControl('f_' + this.field.id + '_allreq'); + } + + this.addControl('f_' + this.field.id); } } diff --git a/src/addon/mod/data/fields/checkbox/providers/handler.ts b/src/addon/mod/data/fields/checkbox/providers/handler.ts index 14632ab59..e307cc6e2 100644 --- a/src/addon/mod/data/fields/checkbox/providers/handler.ts +++ b/src/addon/mod/data/fields/checkbox/providers/handler.ts @@ -49,20 +49,22 @@ export class AddonModDataFieldCheckboxHandler implements AddonModDataFieldHandle const fieldName = 'f_' + field.id, reqName = 'f_' + field.id + '_allreq'; - const checkboxes = [], + const options = field.param1.split('\n'), + checkboxes = [], values = []; - inputData[fieldName].forEach((value, option) => { - if (value) { + options.forEach((option) => { + if (inputData[fieldName + '_' + option]) { checkboxes.push(option); } }); + if (checkboxes.length > 0) { values.push({ name: fieldName, value: checkboxes }); - if (inputData[reqName]['1']) { + if (inputData[reqName]) { values.push({ name: reqName, value: true @@ -85,9 +87,10 @@ export class AddonModDataFieldCheckboxHandler implements AddonModDataFieldHandle getFieldEditData(field: any, inputData: any, originalFieldData: any): any { const fieldName = 'f_' + field.id; - const checkboxes = []; - inputData[fieldName].forEach((value, option) => { - if (value) { + const options = field.param1.split('\n'), + checkboxes = []; + options.forEach((option) => { + if (inputData[fieldName + '_' + option]) { checkboxes.push(option); } }); diff --git a/src/addon/mod/data/fields/date/component/date.html b/src/addon/mod/data/fields/date/component/date.html index 66a9c8de0..41aa4d756 100644 --- a/src/addon/mod/data/fields/date/component/date.html +++ b/src/addon/mod/data/fields/date/component/date.html @@ -1,12 +1,14 @@ - - - + + + + - - {{ 'addon.mod_data.usedate' | translate }} - - - + + {{ 'addon.mod_data.usedate' | translate }} + + + + diff --git a/src/addon/mod/data/fields/date/component/date.ts b/src/addon/mod/data/fields/date/component/date.ts index 034669864..1ea4b8656 100644 --- a/src/addon/mod/data/fields/date/component/date.ts +++ b/src/addon/mod/data/fields/date/component/date.ts @@ -11,10 +11,9 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; +import { CoreTimeUtilsProvider } from '@providers/utils/time'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -26,14 +25,13 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; values = {}; enable: boolean; val: any; + format: string; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder, protected timeUtils: CoreTimeUtilsProvider) { + super(fb); } /** @@ -49,15 +47,23 @@ export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginCompo return; } - if (this.mode == 'edit' && this.value) { - this.enable = true; - } else { + if (!this.value) { this.value = { content: Math.floor(Date.now() / 1000) }; - this.enable = false; } this.val = new Date(this.value.content * 1000); + + this.format = this.timeUtils.getLocalizedDateFormat('LL'); + + if (this.mode == 'search') { + this.addControl('f_' + this.field.id + '_z'); + this.search['f_' + this.field.id] = this.search['f_' + this.field.id + '_y'] ? new Date( + this.search['f_' + this.field.id + '_y'] + '-' + this.search['f_' + this.field.id + '_m'] + '-' + + this.search['f_' + this.field.id + '_d']) : this.val; + } + + this.addControl('f_' + this.field.id, this.val); } } diff --git a/src/addon/mod/data/fields/date/providers/handler.ts b/src/addon/mod/data/fields/date/providers/handler.ts index 9bb37150b..c96d1c65f 100644 --- a/src/addon/mod/data/fields/date/providers/handler.ts +++ b/src/addon/mod/data/fields/date/providers/handler.ts @@ -49,7 +49,7 @@ export class AddonModDataFieldDateHandler implements AddonModDataFieldHandler { const fieldName = 'f_' + field.id, enabledName = 'f_' + field.id + '_z'; - if (inputData[enabledName]['1']) { + if (inputData[enabledName] && typeof inputData[fieldName] == 'string') { const values = [], date = inputData[fieldName].split('-'), year = date[0], diff --git a/src/addon/mod/data/fields/file/component/file.html b/src/addon/mod/data/fields/file/component/file.html index 1ed18a0f3..2416b3c6c 100644 --- a/src/addon/mod/data/fields/file/component/file.html +++ b/src/addon/mod/data/fields/file/component/file.html @@ -1,7 +1,12 @@ - - - - + + + + + + + + +
diff --git a/src/addon/mod/data/fields/file/component/file.ts b/src/addon/mod/data/fields/file/component/file.ts index 773a3b7ed..b802d6f17 100644 --- a/src/addon/mod/data/fields/file/component/file.ts +++ b/src/addon/mod/data/fields/file/component/file.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; import { CoreFileSessionProvider } from '@providers/file-session'; import { AddonModDataProvider } from '../../../providers/data'; @@ -28,15 +26,13 @@ import { AddonModDataProvider } from '../../../providers/data'; }) export class AddonModDataFieldFileComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; files = []; component: string; componentId: number; maxSizeBytes: number; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef, private fileSessionprovider: CoreFileSessionProvider) { - super(); + constructor(protected fb: FormBuilder, private fileSessionprovider: CoreFileSessionProvider) { + super(fb); } /** @@ -77,5 +73,7 @@ export class AddonModDataFieldFileComponent extends AddonModDataFieldPluginCompo this.fileSessionprovider.setFiles(this.component, this.database.id + '_' + this.field.id, this.files); } } + + this.addControl('f_' + this.field.id); } } diff --git a/src/addon/mod/data/fields/latlong/component/latlong.html b/src/addon/mod/data/fields/latlong/component/latlong.html index 0b2ef6c9e..9303ec6d7 100644 --- a/src/addon/mod/data/fields/latlong/component/latlong.html +++ b/src/addon/mod/data/fields/latlong/component/latlong.html @@ -1,17 +1,19 @@ - + + - + - + - - - °N - - - - °E - + + + °N + + + + °E + + diff --git a/src/addon/mod/data/fields/latlong/component/latlong.ts b/src/addon/mod/data/fields/latlong/component/latlong.ts index 2d4e555a8..f9933bf6e 100644 --- a/src/addon/mod/data/fields/latlong/component/latlong.ts +++ b/src/addon/mod/data/fields/latlong/component/latlong.ts @@ -11,11 +11,9 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { Platform } from 'ionic-angular'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -27,14 +25,11 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; - values = {}; north: number; east: number; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef, private platform: Platform) { - super(); + constructor(protected fb: FormBuilder, private platform: Platform) { + super(fb); } /** @@ -86,5 +81,12 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo this.north = (this.value && parseFloat(this.value.content)) || null; this.east = (this.value && parseFloat(this.value.content1)) || null; } + + if (this.mode == 'edit') { + this.addControl('f_' + this.field.id + '_0', this.north); + this.addControl('f_' + this.field.id + '_1', this.east); + } else if (this.mode == 'search') { + this.addControl('f_' + this.field.id); + } } } diff --git a/src/addon/mod/data/fields/menu/component/menu.html b/src/addon/mod/data/fields/menu/component/menu.html index 12f41a13f..c7e9e03c8 100644 --- a/src/addon/mod/data/fields/menu/component/menu.html +++ b/src/addon/mod/data/fields/menu/component/menu.html @@ -1,9 +1,11 @@ - - + + + - - {{ 'addon.mod_data.menuchoose' | translate }} - {{option}} - + + {{ 'addon.mod_data.menuchoose' | translate }} + {{option}} + + \ No newline at end of file diff --git a/src/addon/mod/data/fields/menu/component/menu.ts b/src/addon/mod/data/fields/menu/component/menu.ts index 08628a556..7a7f867bf 100644 --- a/src/addon/mod/data/fields/menu/component/menu.ts +++ b/src/addon/mod/data/fields/menu/component/menu.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -26,13 +24,10 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldMenuComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; - val: string; options = []; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder) { + super(fb); } /** @@ -50,8 +45,11 @@ export class AddonModDataFieldMenuComponent extends AddonModDataFieldPluginCompo this.options = this.field.param1.split('\n'); + let val; if (this.mode == 'edit' && this.value) { - this.val = this.value.content; + val = this.value.content; } + + this.addControl('f_' + this.field.id, val); } } diff --git a/src/addon/mod/data/fields/multimenu/component/multimenu.html b/src/addon/mod/data/fields/multimenu/component/multimenu.html index fbf41a7d7..6bd9c1bd6 100644 --- a/src/addon/mod/data/fields/multimenu/component/multimenu.html +++ b/src/addon/mod/data/fields/multimenu/component/multimenu.html @@ -1,8 +1,17 @@ - - + + + - - \ No newline at end of file + + {{ 'addon.mod_data.selectedrequired' | translate }} + + + + + + \ No newline at end of file diff --git a/src/addon/mod/data/fields/multimenu/component/multimenu.ts b/src/addon/mod/data/fields/multimenu/component/multimenu.ts index c233c08c2..963b279f9 100644 --- a/src/addon/mod/data/fields/multimenu/component/multimenu.ts +++ b/src/addon/mod/data/fields/multimenu/component/multimenu.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -26,12 +24,10 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; options = []; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder) { + super(fb); } /** @@ -44,6 +40,8 @@ export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPlugin protected render(): void { if (this.mode == 'show') { + this.value.content = this.value && this.value.content && this.value.content.split('##').join('
'); + return; } @@ -59,5 +57,11 @@ export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPlugin } }); } + + if (this.mode == 'search') { + this.addControl('f_' + this.field.id + '_allreq'); + } + + this.addControl('f_' + this.field.id); } } diff --git a/src/addon/mod/data/fields/multimenu/providers/handler.ts b/src/addon/mod/data/fields/multimenu/providers/handler.ts index 9f65ee8bf..c5d5c5fcc 100644 --- a/src/addon/mod/data/fields/multimenu/providers/handler.ts +++ b/src/addon/mod/data/fields/multimenu/providers/handler.ts @@ -49,25 +49,22 @@ export class AddonModDataFieldMultimenuHandler implements AddonModDataFieldHandl const fieldName = 'f_' + field.id, reqName = 'f_' + field.id + '_allreq'; - if (inputData[fieldName].length > 0) { - const options = inputData[fieldName].split('###'), - values = []; + if (inputData[fieldName] && inputData[fieldName].length > 0) { + const values = []; - if (options.length > 0) { + values.push({ + name: fieldName, + value: inputData[fieldName] + }); + + if (inputData[reqName]) { values.push({ - name: fieldName, - value: options + name: reqName, + value: true }); - - if (inputData[reqName]['1']) { - values.push({ - name: reqName, - value: true - }); - } - - return values; } + + return values; } return false; diff --git a/src/addon/mod/data/fields/number/component/number.html b/src/addon/mod/data/fields/number/component/number.html index 41bbe1fb0..17a4a6423 100644 --- a/src/addon/mod/data/fields/number/component/number.html +++ b/src/addon/mod/data/fields/number/component/number.html @@ -1,7 +1,9 @@ - + + - + - + + - \ No newline at end of file + diff --git a/src/addon/mod/data/fields/number/component/number.ts b/src/addon/mod/data/fields/number/component/number.ts index c463ea5e4..9fe4d6472 100644 --- a/src/addon/mod/data/fields/number/component/number.ts +++ b/src/addon/mod/data/fields/number/component/number.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -26,12 +24,10 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldNumberComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; val: number; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder) { + super(fb); } /** @@ -50,5 +46,7 @@ export class AddonModDataFieldNumberComponent extends AddonModDataFieldPluginCom if (this.mode == 'edit' && this.value) { this.val = this.value && parseFloat(this.value.content); } + + this.addControl('f_' + this.field.id, this.val); } } diff --git a/src/addon/mod/data/fields/picture/component/picture.html b/src/addon/mod/data/fields/picture/component/picture.html index e435409f8..7b24e5a3f 100644 --- a/src/addon/mod/data/fields/picture/component/picture.html +++ b/src/addon/mod/data/fields/picture/component/picture.html @@ -1,16 +1,20 @@ - + + - + - + - + + {{ 'addon.mod_data.alttext' | translate }} + + °N + + - - {{ 'addon.mod_data.alttext' | translate }} - - °N - + + + diff --git a/src/addon/mod/data/fields/picture/component/picture.ts b/src/addon/mod/data/fields/picture/component/picture.ts index b4516a4a3..810b63cc7 100644 --- a/src/addon/mod/data/fields/picture/component/picture.ts +++ b/src/addon/mod/data/fields/picture/component/picture.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; import { CoreFileSessionProvider } from '@providers/file-session'; import { AddonModDataProvider } from '../../../providers/data'; @@ -28,7 +26,6 @@ import { AddonModDataProvider } from '../../../providers/data'; }) export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; files = []; component: string; componentId: number; @@ -42,9 +39,8 @@ export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginCo width: string; height: string; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef, private fileSessionprovider: CoreFileSessionProvider) { - super(); + constructor(protected fb: FormBuilder, private fileSessionprovider: CoreFileSessionProvider) { + super(fb); } /** @@ -124,5 +120,7 @@ export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginCo this.height = this.field.param2 || ''; } } + + this.addControl('f_' + this.field.id); } } diff --git a/src/addon/mod/data/fields/radiobutton/component/radiobutton.html b/src/addon/mod/data/fields/radiobutton/component/radiobutton.html index 12f41a13f..c7e9e03c8 100644 --- a/src/addon/mod/data/fields/radiobutton/component/radiobutton.html +++ b/src/addon/mod/data/fields/radiobutton/component/radiobutton.html @@ -1,9 +1,11 @@ - - + + + - - {{ 'addon.mod_data.menuchoose' | translate }} - {{option}} - + + {{ 'addon.mod_data.menuchoose' | translate }} + {{option}} + + \ No newline at end of file diff --git a/src/addon/mod/data/fields/radiobutton/component/radiobutton.ts b/src/addon/mod/data/fields/radiobutton/component/radiobutton.ts index 208d5d2cb..400d3aa78 100644 --- a/src/addon/mod/data/fields/radiobutton/component/radiobutton.ts +++ b/src/addon/mod/data/fields/radiobutton/component/radiobutton.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -26,13 +24,10 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldRadiobuttonComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; - options: number; - val: number; + options = []; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder) { + super(fb); } /** @@ -48,10 +43,13 @@ export class AddonModDataFieldRadiobuttonComponent extends AddonModDataFieldPlug return; } - this.options = this.field.param1.split('\n'); + this.options = this.field.param1.split('\n'); + let val; if (this.mode == 'edit' && this.value) { - this.val = this.value.content; + val = this.value.content; } + + this.addControl('f_' + this.field.id, val); } } diff --git a/src/addon/mod/data/fields/text/component/text.html b/src/addon/mod/data/fields/text/component/text.html index d907c4a9c..ad562369f 100644 --- a/src/addon/mod/data/fields/text/component/text.html +++ b/src/addon/mod/data/fields/text/component/text.html @@ -1,7 +1,9 @@ - + + - + - + + \ No newline at end of file diff --git a/src/addon/mod/data/fields/text/component/text.ts b/src/addon/mod/data/fields/text/component/text.ts index 174bc1cd2..ce5f91649 100644 --- a/src/addon/mod/data/fields/text/component/text.ts +++ b/src/addon/mod/data/fields/text/component/text.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -26,12 +24,10 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldTextComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; val: number; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder) { + super(fb); } /** @@ -50,5 +46,7 @@ export class AddonModDataFieldTextComponent extends AddonModDataFieldPluginCompo if (this.mode == 'edit' && this.value) { this.val = this.value.content; } + + this.addControl('f_' + this.field.id, this.val); } } diff --git a/src/addon/mod/data/fields/textarea/component/textarea.html b/src/addon/mod/data/fields/textarea/component/textarea.html index 5a625183b..d7948298b 100644 --- a/src/addon/mod/data/fields/textarea/component/textarea.html +++ b/src/addon/mod/data/fields/textarea/component/textarea.html @@ -1,10 +1,13 @@ - + - + - + - - + + + + + \ No newline at end of file diff --git a/src/addon/mod/data/fields/textarea/component/textarea.ts b/src/addon/mod/data/fields/textarea/component/textarea.ts index 83336cff7..24bf5ecf9 100644 --- a/src/addon/mod/data/fields/textarea/component/textarea.ts +++ b/src/addon/mod/data/fields/textarea/component/textarea.ts @@ -11,9 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { CoreTextUtilsProvider } from '@providers/utils/text'; import { AddonModDataProvider } from '../../../providers/data'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; @@ -27,13 +26,11 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldTextareaComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; component: string; componentId: number; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder, protected textUtils: CoreTextUtilsProvider) { + super(fb); } format(value: any): string { @@ -62,8 +59,8 @@ export class AddonModDataFieldTextareaComponent extends AddonModDataFieldPluginC if (this.mode == 'edit') { const files = (this.value && this.value.files) || [], text = this.value ? this.textUtils.replacePluginfileUrls(this.value.content, files) : ''; - - this.control = this.fb.control(text); } + + this.addControl('f_' + this.field.id, ''); } } diff --git a/src/addon/mod/data/fields/url/component/url.html b/src/addon/mod/data/fields/url/component/url.html index 9212b3aae..e7ff179db 100644 --- a/src/addon/mod/data/fields/url/component/url.html +++ b/src/addon/mod/data/fields/url/component/url.html @@ -1,7 +1,9 @@ - + + - + - + + {{field.name}} \ No newline at end of file diff --git a/src/addon/mod/data/fields/url/component/url.ts b/src/addon/mod/data/fields/url/component/url.ts index 15ac1f53f..e4395fb75 100644 --- a/src/addon/mod/data/fields/url/component/url.ts +++ b/src/addon/mod/data/fields/url/component/url.ts @@ -11,10 +11,8 @@ // 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, OnInit, ElementRef } from '@angular/core'; -import { FormBuilder, FormControl } from '@angular/forms'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreTextUtilsProvider } from '@providers/utils/text'; +import { Component, OnInit } from '@angular/core'; +import { FormBuilder } from '@angular/forms'; import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component'; /** @@ -26,12 +24,10 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- }) export class AddonModDataFieldUrlComponent extends AddonModDataFieldPluginComponent implements OnInit { - control: FormControl; val: number; - constructor(protected fb: FormBuilder, protected domUtils: CoreDomUtilsProvider, protected textUtils: CoreTextUtilsProvider, - element: ElementRef) { - super(); + constructor(protected fb: FormBuilder) { + super(fb); } /** @@ -50,5 +46,7 @@ export class AddonModDataFieldUrlComponent extends AddonModDataFieldPluginCompon if (this.mode == 'edit' && this.value) { this.val = this.value.content; } + + this.addControl('f_' + this.field.id, this.val); } } diff --git a/src/addon/mod/data/pages/search/search.html b/src/addon/mod/data/pages/search/search.html new file mode 100644 index 000000000..ad1be4d75 --- /dev/null +++ b/src/addon/mod/data/pages/search/search.html @@ -0,0 +1,55 @@ + + + {{ 'addon.mod_data.search' | translate }} + + + + + + + +
+ + + + + + {{ 'core.sortby' | translate }} + + + {{field.name}} + + + {{ 'addon.mod_data.timeadded' | translate }} + {{ 'addon.mod_data.timemodified' | translate }} + {{ 'addon.mod_data.authorfirstname' | translate }} + {{ 'addon.mod_data.authorlastname' | translate }} + {{ 'addon.mod_data.approved' | translate }} + + + + + + {{ 'addon.mod_data.ascending' | translate }} + + + + {{ 'addon.mod_data.descending' | translate }} + + + + + + +
+
diff --git a/src/addon/mod/data/pages/search/search.module.ts b/src/addon/mod/data/pages/search/search.module.ts new file mode 100644 index 000000000..09b8cfa41 --- /dev/null +++ b/src/addon/mod/data/pages/search/search.module.ts @@ -0,0 +1,35 @@ +// (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 { CoreDirectivesModule } from '@directives/directives.module'; +import { AddonModDataComponentsModule } from '../../components/components.module'; +import { AddonModDataSearchPage } from './search'; +import { CoreCompileHtmlComponentModule } from '@core/compile/components/compile-html/compile-html.module'; + +@NgModule({ + declarations: [ + AddonModDataSearchPage, + ], + imports: [ + CoreDirectivesModule, + AddonModDataComponentsModule, + CoreCompileHtmlComponentModule, + IonicPageModule.forChild(AddonModDataSearchPage), + TranslateModule.forChild() + ], +}) +export class AddonModDataSearchPageModule {} diff --git a/src/addon/mod/data/pages/search/search.scss b/src/addon/mod/data/pages/search/search.scss new file mode 100644 index 000000000..4ca495a75 --- /dev/null +++ b/src/addon/mod/data/pages/search/search.scss @@ -0,0 +1,57 @@ +page-addon-mod-data-search { + form { + background-color: $list-background-color; + } + + table { + width: 100%; + } + td { + vertical-align: top; + } + + .addon-data-advanced-search { + background-color: $list-background-color; + + @if ($text-input-md-show-focus-highlight) { + .input-md input:focus { + @include md-input-highlight($text-input-md-highlight-color); + } + } + + .input-md input { + @include padding-horizontal(null, ($item-md-padding-end / 2)); + border-bottom: 1px solid $list-md-border-color; + &:focus { + @include md-input-highlight($text-input-md-highlight-color); + } + } + + .input-ios input { + @include padding-horizontal(null, $item-ios-padding-end / 2); + @include safe-area-padding-horizontal(null, $item-ios-padding-end / 2); + border-bottom: $hairlines-width solid $list-ios-border-color; + &:focus { + @include ios-input-highlight($text-input-ios-highlight-color); + } + } + + .input-wp input { + @include padding-horizontal(null, ($item-wp-padding-end / 2)); + border-bottom: 1px solid $list-wp-border-color; + &:focus { + border-color: $text-input-wp-highlight-color; + } + } + + ion-select { + width: 100%; + left: 0; + max-width: none; + } + + .core-item-has-rich-text-editor { + margin-right: 1px; + } + } +} \ No newline at end of file diff --git a/src/addon/mod/data/pages/search/search.ts b/src/addon/mod/data/pages/search/search.ts new file mode 100644 index 000000000..d50a121ec --- /dev/null +++ b/src/addon/mod/data/pages/search/search.ts @@ -0,0 +1,189 @@ +// (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, ViewController } from 'ionic-angular'; +import { FormBuilder, FormGroup } from '@angular/forms'; +import { CoreUtilsProvider } from '@providers/utils/utils'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; +import { AddonModDataComponentsModule } from '../../components/components.module'; +import { AddonModDataFieldsDelegate } from '../../providers/fields-delegate'; + +/** + * Page that displays the search modal. + */ +@IonicPage({ segment: 'addon-mod-data-search' }) +@Component({ + selector: 'page-addon-mod-data-search', + templateUrl: 'search.html', +}) +export class AddonModDataSearchPage { + search: any; + fields: any; + data: any; + advancedSearch: any; + extraImports = [AddonModDataComponentsModule]; + searchForm: FormGroup; + jsData: any; + fieldsArray: any; + + constructor(params: NavParams, private viewCtrl: ViewController, fb: FormBuilder, protected utils: CoreUtilsProvider, + protected domUtils: CoreDomUtilsProvider, protected fieldsDelegate: AddonModDataFieldsDelegate) { + this.search = params.get('search'); + this.fields = params.get('fields'); + this.data = params.get('data'); + + const advanced = {}; + this.search.advanced.forEach((field) => { + advanced[field.name] = field.value ? JSON.parse(field.value) : ''; + }); + this.search.advanced = advanced; + + this.searchForm = fb.group({ + text: [this.search.text], + sortBy: [this.search.sortBy], + sortDirection: [this.search.sortDirection], + firstname: [this.search.advanced['firstname'] || ''], + lastname: [this.search.advanced['lastname'] || ''] + }); + + this.fieldsArray = this.utils.objectToArray(this.fields); + this.advancedSearch = this.renderAdvancedSearchFields(); + } + + /** + * Displays Advanced Search Fields. + * + * @return {string} Generated HTML. + */ + protected renderAdvancedSearchFields(): string { + if (!this.data.asearchtemplate) { + return ''; + } + + this.jsData = { + fields: this.fields, + form: this.searchForm, + search: this.search.advanced + }; + + let template = this.data.asearchtemplate, + replace, render; + + // Replace the fields found on template. + this.fieldsArray.forEach((field) => { + replace = '[[' + field.name + ']]'; + replace = replace.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); + replace = new RegExp(replace, 'gi'); + + // Replace field by a generic directive. + render = ''; + template = template.replace(replace, render); + }); + + // Not pluginable other search elements. + // Replace firstname field by the text input. + replace = new RegExp('##firstname##', 'gi'); + render = ''; + template = template.replace(replace, render); + + // Replace lastname field by the text input. + replace = new RegExp('##lastname##', 'gi'); + render = ''; + template = template.replace(replace, render); + + return template; + } + + /** + * Retrieve the entered data in search in a form. + * + * @param {any} searchedData Array with the entered form values. + * @return {any[]} Array with the answers. + */ + getSearchDataFromForm(searchedData: any): any[] { + const advancedSearch = []; + + // Filter and translate fields to each field plugin. + this.fieldsArray.forEach((field) => { + const fieldData = this.fieldsDelegate.getFieldSearchData(field, searchedData); + + if (fieldData) { + fieldData.forEach((data) => { + data.value = JSON.stringify(data.value); + // WS wants values in Json format. + advancedSearch.push(data); + }); + } + }); + + // Not pluginable other search elements. + if (searchedData['firstname']) { + // WS wants values in Json format. + advancedSearch.push({ + name: 'firstname', + value: JSON.stringify(searchedData['firstname']) + }); + } + + if (searchedData['lastname']) { + // WS wants values in Json format. + advancedSearch.push({ + name: 'lastname', + value: JSON.stringify(searchedData['lastname']) + }); + } + + return advancedSearch; + } + + /** + * Close modal. + * + * @param {any} [data] Data to return to the page. + */ + closeModal(data?: any): void { + this.viewCtrl.dismiss(data); + } + + /** + * Toggles between advanced to normal search. + */ + toggleAdvanced(): void { + this.search.searchingAdvanced = !this.search.searchingAdvanced; + } + + /** + * Done editing. + */ + searchEntries(): void { + const searchedData = this.searchForm.value; + + if (this.search.searchingAdvanced) { + this.search.advanced = this.getSearchDataFromForm(searchedData); + this.search.searching = this.search.advanced.length > 0; + } else { + this.search.text = searchedData.text; + this.search.searching = this.search.text.length > 0; + } + + this.search.sortBy = searchedData.sortBy; + this.search.sortDirection = searchedData.sortDirection; + + this.closeModal(this.search); + } +} diff --git a/src/addon/mod/data/providers/helper.ts b/src/addon/mod/data/providers/helper.ts index 52e90e251..6bba1cea2 100644 --- a/src/addon/mod/data/providers/helper.ts +++ b/src/addon/mod/data/providers/helper.ts @@ -92,46 +92,6 @@ export class AddonModDataHelperProvider { }); } - /** - * Displays Advanced Search Fields. - * - * @param {string} template Template HMTL. - * @param {any[]} fields Fields that defines every content in the entry. - * @return {string} Generated HTML. - */ - displayAdvancedSearchFields(template: string, fields: any[]): string { - if (!template) { - return ''; - } - - let replace; - - // Replace the fields found on template. - fields.forEach((field) => { - replace = '[[' + field.name + ']]'; - replace = replace.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); - replace = new RegExp(replace, 'gi'); - - // Replace field by a generic directive. - const render = ''; - template = template.replace(replace, render); - }); - - // Not pluginable other search elements. - // Replace firstname field by the text input. - replace = new RegExp('##fn##', 'gi'); - let render = ''; - template = template.replace(replace, render); - - // Replace lastname field by the text input. - replace = new RegExp('##ln##', 'gi'); - render = ''; - template = template.replace(replace, render); - - return template; - } - /** * Displays fields for being shown. * @@ -215,55 +175,6 @@ export class AddonModDataHelperProvider { }; } - /** - * Retrieve the entered data in search in a form. - * We don't use ng-model because it doesn't detect changes done by JavaScript. - * - * @param {any} form Form (DOM element). - * @param {any[]} fields Fields that defines every content in the entry. - * @return {any[]} Array with the answers. - */ - getSearchDataFromForm(form: any, fields: any[]): any[] { - if (!form || !form.elements) { - return []; - } - - const searchedData = this.domUtils.getDataFromForm(form); - - // Filter and translate fields to each field plugin. - const advancedSearch = []; - fields.forEach((field) => { - const fieldData = this.fieldsDelegate.getFieldSearchData(field, searchedData); - - if (fieldData) { - fieldData.forEach((data) => { - data.value = JSON.stringify(data.value); - // WS wants values in Json format. - advancedSearch.push(data); - }); - } - }); - - // Not pluginable other search elements. - if (searchedData['firstname']) { - // WS wants values in Json format. - advancedSearch.push({ - name: 'firstname', - value: JSON.stringify(searchedData['firstname']) - }); - } - - if (searchedData['lastname']) { - // WS wants values in Json format. - advancedSearch.push({ - name: 'lastname', - value: JSON.stringify(searchedData['lastname']) - }); - } - - return advancedSearch; - } - /** * Get a list of stored attachment files for a new entry. See $mmaModDataHelper#storeFiles. * diff --git a/src/app/app.scss b/src/app/app.scss index 510ee0f62..b8ea96c8f 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -171,6 +171,10 @@ ion-avatar ion-img, ion-avatar img { font-style: italic; } +ion-datetime { + position: relative; +} + /** Format Text */ core-format-text[maxHeight], *[core-format-text][maxHeight], core-format-text[ng-reflect-max-height], *[core-format-text][ng-reflect-max-height] { diff --git a/src/components/tabs/tabs.scss b/src/components/tabs/tabs.scss index 09e3ec64a..56b3113aa 100644 --- a/src/components/tabs/tabs.scss +++ b/src/components/tabs/tabs.scss @@ -1,28 +1,59 @@ -core-tabs { - .core-tabs-bar { - left: 0; - position: relative; - z-index: $z-index-toolbar; - display: flex; - width: 100%; +.core-tabs-bar { + left: 0; + position: relative; + z-index: $z-index-toolbar; + display: flex; + width: 100%; + background: $core-top-tabs-background; + + > a { + @extend .tab-button; + background: $core-top-tabs-background; + color: $core-top-tabs-color !important; + font-size: 1.6rem; + border: 0; - > a { - @extend .tab-button; - - background: $core-top-tabs-background; - color: $core-top-tabs-color !important; - font-size: 1.6rem; - border: 0; - - &[aria-selected=true] { - color: $core-top-tabs-color-active !important; - border: 0 !important; - border-bottom: 2px solid $core-top-tabs-color-active !important; - } + &[aria-selected=true] { + color: $core-top-tabs-color-active !important; + border: 0 !important; + border-bottom: 2px solid $core-top-tabs-color-active !important; } } +} +.md .core-tabs-bar > a { + // @extend .tabs-md .tab-button; + min-height: $tabs-md-tab-min-height; + + font-weight: $tabs-md-tab-font-weight; + color: $tabs-md-tab-text-color; +} + +.ios .core-tabs-bar > a { + // @extend .tabs-ios .tab-button; + max-width: $tabs-ios-tab-max-width; + min-height: $tabs-ios-tab-min-height; + + font-size: $tabs-ios-tab-font-size; + font-weight: $tabs-ios-tab-font-weight; + color: $tabs-ios-tab-text-color; +} + +.wp .core-tabs-bar > a { + //@extend .tabs-wp .tab-button; + @include border-radius(0); + + min-height: $tabs-wp-tab-min-height; + + border-bottom: $tabs-wp-tab-border; + font-size: $tabs-wp-tab-font-size; + font-weight: $tabs-wp-tab-font-weight; + color: $tabs-wp-tab-color; + box-shadow: none; +} + +core-tabs { .core-tabs-content-container { height: 100%; @@ -47,7 +78,7 @@ core-tabs { } } - core-tab { + core-tab, .core-tab { display: none; height: 100%; position: relative; @@ -71,22 +102,18 @@ core-tabs { overflow: hidden !important; } -.ios core-tabs { - .core-tabs-bar { - -webkit-box-pack: center; - -webkit-justify-content: center; - -ms-flex-pack: center; - justify-content: center; - > a { - font-size: 1.6rem; - } +.ios .core-tabs-bar { + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + > a { + font-size: 1.6rem; } } -.md core-tabs { - .core-tabs-bar::after { - @extend .header-md::after; - } +.md .core-tabs-bar::after { + @extend .header-md::after; } .ios, .md, .wp {