Best JavaScript code snippet using stryker-parent
FixedFilterViewV2.NUI.js
Source:FixedFilterViewV2.NUI.js
1define("FixedFilterViewV2", ["ext-base", "terrasoft", "FixedFilterViewV2Resources"],2 function(Ext, Terrasoft, resources) {3 /**4 * ######### ############ ############ ######## ## #######.5 * @param {Object} filterConfig ############ ############ ########.6 * @return {Object} ############ ############ ######## ## #######.7 */8 function getPeriodFilterConfig(filterConfig) {9 var resultConfig = {};10 var startDateColumnName = filterConfig.columnName;11 var startDateDefValue = filterConfig.defValue || null;12 var dueDateColumnName = filterConfig.columnName;13 var dueDateDefValue = filterConfig.defValue || null;14 if (filterConfig.startDate) {15 startDateColumnName = filterConfig.startDate.columnName || startDateColumnName;16 startDateDefValue = filterConfig.startDate.defValue || startDateDefValue;17 if (filterConfig.dueDate) {18 dueDateColumnName = filterConfig.dueDate.columnName || startDateColumnName || dueDateColumnName;19 dueDateDefValue = filterConfig.dueDate.defValue || startDateDefValue || dueDateDefValue;20 } else {21 dueDateColumnName = startDateColumnName;22 dueDateDefValue = startDateDefValue;23 }24 }25 if (startDateColumnName === dueDateColumnName) {26 dueDateColumnName = startDateColumnName + "Due";27 resultConfig.singleColumn = true;28 }29 resultConfig.startDateColumnName = startDateColumnName;30 resultConfig.startDateDefValue = startDateDefValue;31 resultConfig.dueDateColumnName = dueDateColumnName;32 resultConfig.dueDateDefValue = dueDateDefValue;33 return resultConfig;34 }35 var filterChangedDefined;36 function getFixedButtonBaseConfig(config) {37 return this.Ext.apply({}, config, {38 className: "Terrasoft.Button",39 style: Terrasoft.controls.ButtonEnums.style.TRANSPARENT,40 hint: resources.localizableStrings.SelectOwnerCaption41 });42 }43 function getPeriodFilterViewConfig(filterConfig) {44 var periodConfig = getPeriodFilterConfig(filterConfig);45 var items = [46 {47 className: "Terrasoft.Container",48 id: "fixedFilter" + filterConfig.name + "ButtonContainer",49 selectors: {50 el: "#fixedFilter" + filterConfig.name + "ButtonContainer",51 wrapEl: "#fixedFilter" + filterConfig.name + "ButtonContainer"52 },53 items: getPeriodFixedButtonsViewConfig(filterConfig.name),54 classes: {55 wrapClassName: "filter-inner-container fixed-filter-element-container-wrap " +56 "fixed-period-filter-element-container-wrap"57 }58 },59 {60 className: "Terrasoft.Container",61 id: "fixedFilter" + filterConfig.name + "ValuesContainer",62 selectors: {63 el: "#fixedFilter" + filterConfig.name + "ValuesContainer",64 wrapEl: "#fixedFilter" + filterConfig.name + "ValuesContainer"65 },66 items: [67 getDateFilterValueLabel(periodConfig, "startDateColumnName",68 resources.localizableStrings.StartDatePlaceholder),69 {70 className: "Terrasoft.Label",71 classes: {72 labelClass: ["filter-caption-label", "filter-element-with-right-space"]73 },74 caption: resources.localizableStrings.PeriodToLabelCaption75 },76 getDateFilterValueLabel(periodConfig, "dueDateColumnName",77 resources.localizableStrings.DueDatePlaceholder),78 {79 className: "Terrasoft.Button",80 style: Terrasoft.controls.ButtonEnums.style.TRANSPARENT,81 hint: resources.localizableStrings.RemoveButtonHint,82 imageConfig: resources.localizableImages.RemoveButtonImage,83 classes: {84 wrapperClass: "filter-remove-button"85 },86 markerValue: "clearPeriodFilter",87 click: {bindTo: "clearPeriodFilter"},88 tag: periodConfig89 }90 ],91 classes: {92 wrapClassName: "filter-inner-container fixed-filter-element-container-wrap"93 }94 }95 ];96 return items;97 }98 function getDateFilterValueLabel(periodConfig, currentColumnName, placeholder) {99 var columnName = periodConfig[currentColumnName];100 var config = {101 id: "fixedFilter" + columnName + "View",102 className: "Terrasoft.LabelDateEdit",103 classes: {104 labelClass: ["filter-value-label", "filter-element-with-right-space"]105 },106 value: {107 bindTo: columnName108 },109 tag: {110 currentColumnName: columnName,111 periodConfig: periodConfig112 },113 placeholder: placeholder114 };115 if (filterChangedDefined) {116 config.change = {117 bindTo: "periodChanged"118 };119 }120 return config;121 }122 /**123 * ########## ###### ######### ### ########## ## #######.124 * @param {String} filterName ######## #######, ### ######## ############.125 * @return {Array} ###### ######### ### ########## ## #######.126 */127 function getPeriodFixedButtonsViewConfig(filterName) {128 var localizableStrings = resources.localizableStrings;129 var localizableImages = resources.localizableImages;130 var dayButton = getFixedButtonBaseConfig({131 click: {bindTo: "setCurrentDayPeriod"},132 hint: localizableStrings.TodayCaption,133 imageConfig: localizableImages.DayPeriodButtonImage,134 markerValue: "day",135 classes: {136 wrapperClass: ["day-period-fixed-filter-wrapper-class"],137 imageClass: ["period-fixed-filter-image-class"]138 },139 visible: {bindTo: "dayButtonVisible"}140 });141 var weekButton = getFixedButtonBaseConfig({142 click: {bindTo: "setCurrentWeekPeriod"},143 hint: localizableStrings.CurrentWeekCaption,144 imageConfig: localizableImages.WeekPeriodButtonImage,145 markerValue: "week",146 classes: {147 wrapperClass: ["day-period-fixed-filter-wrapper-class"],148 imageClass: ["period-fixed-filter-image-class"]149 },150 visible: {bindTo: "weekButtonVisible"}151 });152 var monthButton = getFixedButtonBaseConfig({153 imageConfig: localizableImages.MonthPeriodButtonImage,154 hint: localizableStrings.SelectPeriodCaption,155 markerValue: "month",156 classes: {157 imageClass: ["period-fixed-filter-image-class"]158 },159 visible: {bindTo: "monthButtonVisible"}160 });161 monthButton.menu = {162 items: [{163 className: "Terrasoft.MenuItem",164 caption: localizableStrings.YesterdayCaption,165 click: {bindTo: "setPeriod"},166 tag: filterName + "_Yesterday"167 }, {168 className: "Terrasoft.MenuItem",169 caption: localizableStrings.TodayCaption,170 click: {bindTo: "setPeriod"},171 tag: filterName + "_Today"172 }, {173 className: "Terrasoft.MenuItem",174 caption: localizableStrings.TomorrowCaption,175 click: {bindTo: "setPeriod"},176 tag: filterName + "_Tomorrow"177 }, {178 className: "Terrasoft.MenuSeparator"179 }, {180 className: "Terrasoft.MenuItem",181 caption: localizableStrings.PastWeekCaption,182 click: {bindTo: "setPeriod"},183 tag: filterName + "_PastWeek"184 }, {185 className: "Terrasoft.MenuItem",186 caption: localizableStrings.CurrentWeekCaption,187 click: {bindTo: "setPeriod"},188 tag: filterName + "_CurrentWeek"189 }, {190 className: "Terrasoft.MenuItem",191 caption: localizableStrings.NextWeekCaption,192 click: {bindTo: "setPeriod"},193 tag: filterName + "_NextWeek"194 }, {195 className: "Terrasoft.MenuSeparator"196 }, {197 className: "Terrasoft.MenuItem",198 caption: localizableStrings.PastMonthCaption,199 click: {bindTo: "setPeriod"},200 tag: filterName + "_PastMonth"201 }, {202 className: "Terrasoft.MenuItem",203 caption: localizableStrings.CurrentMonthCaption,204 click: {bindTo: "setPeriod"},205 tag: filterName + "_CurrentMonth"206 }, {207 className: "Terrasoft.MenuItem",208 caption: localizableStrings.NextMonthCaption,209 click: {bindTo: "setPeriod"},210 tag: filterName + "_NextMonth"211 }]212 };213 return [dayButton, weekButton, monthButton];214 }215 /**216 * Returns view config for custom filter button.217 * @protected218 * @param {Object} filterConfig Initial filter button config.219 * @return {Object[]}220 */221 function getCustomFixedButtonConfig(filterConfig) {222 var config = getFixedButtonBaseConfig();223 config.caption = {224 bindTo: filterConfig.name + "ButtonCaption"225 };226 config.markerValue = filterConfig.markerValue || "OwnerFixedFilterBtn";227 config.imageConfig = filterConfig.buttonImageConfig || resources.localizableImages.LookupButtonImage;228 config.menu = {items: getMenuButtonItems(filterConfig)};229 config.hint = Ext.isDefined(filterConfig.hint) ? filterConfig.hint : config.hint;230 return [config];231 }232 /**233 * Returns an array of menu items for custom fixed filter button.234 * @protected235 * @param {Object} filterConfig Filter configuration.236 * @return {Object[]} Menu items.237 */238 function getMenuButtonItems(filterConfig) {239 var items = [];240 if (filterConfig.appendCurrentContactMenuItem !== false) {241 items.push(242 {243 className: "Terrasoft.MenuItem",244 caption: Terrasoft.SysValue.CURRENT_USER_CONTACT.displayValue,245 click: {246 bindTo: "setCurrentContact"247 },248 markerValue: "SetCurrentUserOwnerFixedFilterMenuItem",249 tag: filterConfig.name250 },251 {252 className: "Terrasoft.MenuSeparator"253 }254 );255 }256 var addNewFilterCaptionConfig = filterConfig.addNewFilterCaption257 ? filterConfig.addNewFilterCaption258 : {bindTo: "addOwnerCaption"};259 var addNewFilterMarkerValue = filterConfig.addNewFilterCaption260 ? filterConfig.addNewFilterCaption261 : "AddOwnerFixedFilterMenuItem";262 items.push(263 {264 className: "Terrasoft.MenuItem",265 caption: addNewFilterCaptionConfig,266 click: {267 bindTo: "addLookupFilter"268 },269 markerValue: addNewFilterMarkerValue,270 tag: filterConfig.name271 },272 {273 className: "Terrasoft.MenuItem",274 caption: resources.localizableStrings.ClearCaption,275 click: {276 bindTo: "clearLookupFilter"277 },278 markerValue: "ClearOwnerFixedFilterMenuItem",279 tag: filterConfig.name280 }281 );282 return items;283 }284 function generate(schema) {285 filterChangedDefined = schema.filterChangedDefined;286 var fixedFilterContainerName = schema.fixedFilterContainerName;287 /*jshint quotmark: false */288 var viewConfig = {289 id: fixedFilterContainerName,290 selectors: {291 el: "#" + fixedFilterContainerName,292 wrapEl: "#" + fixedFilterContainerName293 },294 classes: {295 wrapClassName: "fixed-filter-container"296 },297 items: [298 ],299 tpl: [300 "<span id=\"{id}\" style=\"{wrapStyles}\" class=\"{wrapClassName}\">",301 "{%this.renderItems(out, values)%}",302 "</span>"303 ]304 };305 /*jshint quotmark: true */306 Terrasoft.each(schema.filters, function(filterConfig) {307 if (!filterConfig.moduleName) {308 var filterViewConfig = getFilterViewConfig(filterConfig);309 viewConfig.items.push(filterViewConfig);310 }311 }, this);312 return viewConfig;313 }314 function getFilterViewConfig(filterConfig) {315 /*jshint quotmark: false */316 var config = {317 className: "Terrasoft.Container",318 id: "fixedFilter" + filterConfig.name + "Container",319 selectors: {320 el: "#fixedFilter" + filterConfig.name + "Container",321 wrapEl: "#fixedFilter" + filterConfig.name + "Container"322 },323 tpl: [324 "<span id=\"{id}\" style=\"{wrapStyles}\" class=\"{wrapClassName}\">",325 "{%this.renderItems(out, values)%}",326 "</span>"327 ],328 items: [329 ]330 };331 /*jshint quotmark: true */332 if (filterConfig.dataValueType === Terrasoft.DataValueType.DATE) {333 config.items = getPeriodFilterViewConfig(filterConfig);334 } else {335 var buttonContainer = {336 className: "Terrasoft.Container",337 id: "fixedFilter" + filterConfig.name + "ButtonContainer",338 selectors: {339 el: "#fixedFilter" + filterConfig.name + "ButtonContainer",340 wrapEl: "#fixedFilter" + filterConfig.name + "ButtonContainer"341 },342 items: getCustomFixedButtonConfig(filterConfig),343 classes: {344 wrapClassName: "filter-inner-container fixed-filter-element-container-wrap " +345 "owner-fixed-filter-container-class"346 }347 };348 config.items.push(buttonContainer);349 }350 return config;351 }352 function generateSimpleEditFilterConfig(filterName, simpleFilterEditContainerName) {353 var viewConfig = {354 id: simpleFilterEditContainerName,355 selectors: {356 el: "#" + simpleFilterEditContainerName,357 wrapEl: "#" + simpleFilterEditContainerName358 },359 classes: {360 wrapClassName: "filter-inner-container"361 },362 items: [363 {364 className: "Terrasoft.LookupEdit",365 classes: {366 wrapClass: "filter-simple-filter-edit"367 },368 value: {369 bindTo: filterName370 },371 list: {372 bindTo: filterName + "List"373 }374 },375 {376 className: "Terrasoft.Button",377 imageConfig: resources.localizableImages.ApplyButtonImage,378 style: Terrasoft.controls.ButtonEnums.style.BLUE,379 classes: {380 wrapperClass: ["filter-element-with-right-space"]381 },382 click: {383 bindTo: "applyFilter"384 },385 tag: filterName386 },387 {388 className: "Terrasoft.Button",389 imageConfig: resources.localizableImages.CancelButtonImage,390 click: {391 bindTo: "destroySimpleFilterEdit"392 },393 tag: filterName394 }395 ],396 destroy: {397 bindTo: "clearSimpleFilterProperties"398 },399 tag: filterName400 };401 return viewConfig;402 }403 return {404 generate: generate,405 generateSimpleEditFilterConfig: generateSimpleEditFilterConfig406 };...
useFilterSelect.js
Source:useFilterSelect.js
1import { useState, useMemo } from "react";2export const useFiltableData = (items, config = null) => {3 const [filterConfig, setFilterConfig] = useState({4 item: [],5 key: "",6 });7 const [filtered, setFiltered] = useState(false);8 const [dataAll, setData] = useState([]);9 const filteredItems = useMemo(() => {10 let filtableItems = items;11 if (filterConfig.item.length > 0 && filterConfig.secondKey) {12 filtableItems = items?.filter((item) =>13 filterConfig.item.includes(14 item[filterConfig.secondKey][filterConfig.column]15 )16 );17 setFiltered(true);18 setData(filtableItems);19 filterConfig.filter = true;20 return filtableItems;21 } else if (filterConfig.item.length > 0 && !filterConfig.search) {22 filtableItems = items?.filter((item) =>23 filterConfig.item.includes(24 Array.isArray(item[filterConfig.column])25 ? item[filterConfig.column].join(" ")26 : item[filterConfig.column]27 )28 );29 setFiltered(true);30 setData(filtableItems);31 filterConfig.filter = true;32 return filtableItems;33 } else if (typeof filterConfig.item === "string") {34 filtableItems = items?.filter((item) =>35 Array.isArray(item[filterConfig.column])36 ? item[filterConfig.column]37 .join(" ")38 .toLowerCase()39 .includes(filterConfig.item)40 : item[filterConfig.column].toLowerCase().includes(filterConfig.item)41 );42 setFiltered(true);43 setData(filtableItems);44 filterConfig.filter = true;45 return filtableItems;46 }47 // setFilterConfig((prevState) => ({ ...prevState, filter: filtered }));48 return filtableItems;49 }, [items, filterConfig]);50 //search button51 const searchButton = (key, column) => {52 if (key) {53 setFilterConfig({ item: key, column, search: true });54 } else {55 setFilterConfig({ item: key, column, search: false });56 }57 };58 const configDisplay = (column) => {59 let display = "Block";60 if (filterConfig.column === column && filterConfig.display) {61 if (display === filterConfig.display) {62 setFilterConfig((prevState) => ({ ...prevState, display: "None" }));63 } else {64 setFilterConfig((prevState) => ({ ...prevState, display: display }));65 }66 } else if (filterConfig.column === column && !filterConfig.display) {67 setFilterConfig((prevState) => ({ ...prevState, display: "Block" }));68 } else {69 setFilterConfig({70 item: [],71 display: display,72 column: column,73 });74 }75 };76 //function to filter77 const requestFilter = (key, column, secondKey = null) => {78 // only if seFilterConfig is not null79 let item = Array.isArray(filterConfig.item) ? filterConfig.item : [];80 if (filterConfig.item.length > 0) {81 if (82 filterConfig.column === column &&83 filterConfig.item.indexOf(key) === -184 ) {85 item.push(key);86 } else {87 item.splice(filterConfig.item.indexOf(key), 1);88 }89 } else {90 item.push(key);91 }92 setFilterConfig({ item: item, column, secondKey });93 };94 const uniqueItems = (key, test = null) => {95 let uniquePropellant = [];96 let data = filtered && filterConfig.column === key ? items : filteredItems;97 console.log(98 filtered,99 data,100 "maduvha",101 filtered && filterConfig.column === key102 );103 if (test) {104 data?.map((item) => {105 if (uniquePropellant?.indexOf(item[test][key]) === -1) {106 uniquePropellant.push(item[test][key]);107 }108 return uniquePropellant;109 });110 } else {111 data?.map((item) => {112 if (Array.isArray(item[key])) {113 for (var i = 0; i < item[key].length; i++) {114 if (uniquePropellant?.indexOf(item[key][i]) === -1) {115 uniquePropellant.push(item[key][i]);116 }117 }118 console.log(filtered, data);119 } else {120 if (uniquePropellant?.indexOf(item[key]) === -1) {121 uniquePropellant.push(item[key]);122 }123 }124 return uniquePropellant;125 });126 }127 return uniquePropellant;128 };129 return {130 requestFilter,131 uniqueItems,132 filteredItems,133 searchButton,134 configDisplay,135 filterConfig,136 };...
helper.ts
Source:helper.ts
1import type { FilterConfig } from "./types";2import { ApolloError } from "apollo-server-express";3/**4 * Helper class to get corresponding DB fields mapping5 */6export class QueryBuilder {7 static getDBFieldName(str: string, filterConfig: FilterConfig) {8 // defalut sorting is by _score, just returned the field as is9 if (str === "_score") {10 return str;11 }12 if (str in filterConfig.filter.arguments) {13 return filterConfig.filter.arguments[str].db_field_name;14 }15 return undefined;16 }17 static getDBFieldType(str: string, filterConfig: FilterConfig) {18 if (str in filterConfig.filter.arguments) {19 return filterConfig.filter.arguments[str].db_type;20 }21 return undefined;22 }23 static getNestedType(str: string, filterConfig: FilterConfig) {24 if (str in filterConfig.filter.arguments) {25 return filterConfig.filter.arguments[str].nested_type;26 }27 return undefined;28 }29 static getMatchItemsQuery(searchItems: { [k: string]: any }, key: string) {30 const queryItems = searchItems.map((item: any) => {31 return {32 match: {33 [key]: item,34 },35 };36 });37 return {38 bool: { should: queryItems },39 };40 }41 static validateField(operation: string, fieldName: string, filterConfig: FilterConfig) {42 let valid = false;43 switch (operation) {44 case "isNull":45 if (filterConfig.filter.isNull.includes(fieldName)) {46 valid = true;47 } else {48 throw new ApolloError(`${fieldName} not allowed in the null list`, "BAD REQUEST", {49 statusCode: 400,50 });51 }52 break;53 case "isNotNull":54 if (filterConfig.filter.isNotNull.includes(fieldName)) {55 valid = true;56 } else {57 throw new ApolloError(`${fieldName} not allowed in the not null list`, "BAD REQUEST", {58 statusCode: 400,59 });60 }61 break;62 default:63 throw new ApolloError("Operation not found in the config", "ERROR", { statusCode: 500 });64 }65 return valid;66 }67 static isCamelCase(arg: string) {68 return /^[a-z][A-Za-z0-9]*$/.test(arg);69 }70 /**71 * Validate the graphQL naming convention72 * @param arg73 */74 static validateGraphQLStandard(arg: string) {75 return this.isCamelCase(arg);76 }77 static getAggsField(str: string, filterConfig: FilterConfig) {78 if (str in filterConfig.filter.arguments) {79 return filterConfig.filter.arguments[str].aggs_field;80 }81 return undefined;82 }83 static getAggsName(str: string, filterConfig: FilterConfig) {84 if (str in filterConfig.filter.arguments) {85 return filterConfig.filter.arguments[str].aggs_name;86 }87 return undefined;88 }89 static getAggsType(str: string, filterConfig: FilterConfig) {90 if (str in filterConfig.filter.arguments) {91 return filterConfig.filter.arguments[str].aggs_type;92 }93 return undefined;94 }...
Using AI Code Generation
1const filterConfig = require('stryker-parent').filterConfig;2filterConfig(config, 'stryker-plugin-name');3const filterConfig = require('stryker-plugin-name').filterConfig;4filterConfig(config, 'stryker-plugin-name');5const filterConfig = require('stryker-plugin-name').filterConfig;6filterConfig(config, 'stryker-plugin-name');7const filterConfig = require('stryker-plugin-name').filterConfig;8filterConfig(config, 'stryker-plugin-name');9const filterConfig = require('stryker-plugin-name').filterConfig;10filterConfig(config, 'stryker-plugin-name');11const filterConfig = require('stryker-plugin-name').filterConfig;12filterConfig(config, 'stryker-plugin-name');13const filterConfig = require('stryker-plugin-name').filterConfig;14filterConfig(config, 'stryker-plugin-name');15const filterConfig = require('stryker-plugin-name').filterConfig;16filterConfig(config, 'stryker-plugin-name');17const filterConfig = require('stryker-plugin-name').filterConfig;18filterConfig(config, 'stryker-plugin-name');19const filterConfig = require('stryker-plugin-name').filterConfig;20filterConfig(config, 'stryker-plugin-name');21const filterConfig = require('stryker-plugin-name').filterConfig;22filterConfig(config, 'stryker-plugin-name');23const filterConfig = require('stryker-plugin-name').filterConfig;24filterConfig(config, 'stryker-plugin-name');25const filterConfig = require('stryker-plugin-name').filterConfig;26filterConfig(config, 'stryker-plugin-name');27const filterConfig = require('
Using AI Code Generation
1const { filterConfig } = require('stryker-parent');2const config = filterConfig({3});4module.exports = config;5const { filterConfig } = require('stryker-parent');6const config = filterConfig({7});8const { filterConfig } = require('stryker-parent');9const config = filterConfig({10}, '4.0.0');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!