Explorar o código

Dropdown modified input fix fro 'Starts with' search

Richard Knight %!s(int64=6) %!d(string=hai) anos
pai
achega
0a122da938

+ 2 - 2
src/app/dynaform/components/custom/dropdown-modified-input/dropdown-modified-input.component.ts

@@ -19,9 +19,9 @@ export class DropdownModifiedInputComponent extends CustomInputComponent impleme
 
 	exposeMetaInTemplate: string[] = ['modifiers', 'transform', 'placeholder'];
 
-	modifiers: Array<string>;
+	modifiers: string[];
 	transform: ValueTransformer = {
-		inputFn: value => ({ modifier: '', value: value }),
+		inputFn: value => ({ modifier: '', value }),
 		outputFn: (modifier, value) => value
 	};
 	private selectedModifier: string;

+ 7 - 7
src/app/dynaform/utils.ts

@@ -1,4 +1,4 @@
-// Some standard utility functions for Dyynaform consumers
+// Utility functions for Dyynaform consumers
 
 import { ValueTransformer } from './interfaces';
 
@@ -8,20 +8,20 @@ const standardTransformer: ValueTransformer = {
 	inputFn: val => {
 		let modifier = 'Starts with';
 		if (/^%.*?%$/.test(val)) {
-			modifier = 'Contains'
+			modifier = 'Contains';
 		} else if (/^[^%].*?[^%]$/.test(val)) {
-			modifier = 'Matches'
+			modifier = 'Matches';
 		} else if (/^%.*/.test(val)) {
 			modifier = 'Starts with';
 		}
 		const transformedVal = val.replace(/%/g, '').trim();
-		return { modifier: modifier, value: transformedVal };
+		return { modifier, value: transformedVal };
 	},
 	outputFn: (mod, val) => {
 		let transformedValue;
-		switch(mod) {
+		switch (mod) {
 			case 'Starts with':
-				transformedValue = `%${val}`;
+				transformedValue = `${val}%`;
 				break;
 			case 'Contains':
 				transformedValue = `%${val}%`;
@@ -52,6 +52,6 @@ const excludeFields = (obj: StringMap, fieldsToExclude: string | string[]) => {
 		(res, [key, val]) => ex.includes(key) ? res : { ...res, [key]: val },
 		{}
 	);
-}
+};
 
 export { standardModifiers, standardTransformer, toArrTag, arrayPad, arrayToMeta, excludeFields };