Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

@newageerp/v3.toolbar.filter-container

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@newageerp/v3.toolbar.filter-container - npm Package Compare versions

Comparing version 0.2.69 to 0.2.70

@@ -5,7 +5,9 @@ import { FC } from 'react';

itemsFilter: TypeItemFilters;
setItemsFilter: (itemsFilter: TypeItemFilters) => void;
addNewBlockFilter: () => void;
clearBlockFilter: () => void;
onFilter: () => void;
schema: string;
};
export declare const Filter: FC<Props>;
export {};

@@ -21,2 +21,11 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -30,5 +39,35 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const classnames_1 = __importDefault(require("classnames"));
const v3_buttons_toolbar_button_1 = require("@newageerp/v3.buttons.toolbar-button");
const v3_layout_theme_provider_1 = require("@newageerp/v3.layout.theme-provider");
const Filter = ({ itemsFilter, addNewBlockFilter, clearBlockFilter, onFilter }) => {
const v3_hooks_use_u_request_1 = require("@newageerp/v3.hooks.use-u-request");
const v3_templates_templates_core_1 = require("@newageerp/v3.templates.templates-core");
const crm_ui_1 = require("@newageerp/crm-ui");
const Filter = ({ itemsFilter, addNewBlockFilter, clearBlockFilter, onFilter, setItemsFilter, schema }) => {
const { userState } = (0, v3_templates_templates_core_1.useTemplatesCore)();
// saved filters
const [savedFilters, setSavedFilters] = (0, react_1.useState)([]);
const [getSavedFiltersReq] = (0, v3_hooks_use_u_request_1.useUList)('sf-system-saved-filter', ['id', 'title', 'filter']);
const [doRemoveSavedFilter] = (0, v3_hooks_use_u_request_1.useURemove)('sf-system-saved-filter');
const [doSaveSavedFilter] = (0, v3_hooks_use_u_request_1.useUSave)('sf-system-saved-filter');
const createSavedSearch = (title) => __awaiter(void 0, void 0, void 0, function* () {
yield doSaveSavedFilter({
title,
filter: itemsFilter,
}, "new");
yield getSavedFilters();
});
const getSavedFilters = () => __awaiter(void 0, void 0, void 0, function* () {
const d = yield getSavedFiltersReq([
{
and: [
['i.userId', '=', userState.id, true],
['i.filterSchema', '=', schema, true],
]
}
], 1, 10000);
setSavedFilters(d.data.data);
});
const removeFavourite = (id) => __awaiter(void 0, void 0, void 0, function* () {
yield doRemoveSavedFilter(id);
yield getSavedFilters();
});
const { theme } = (0, v3_layout_theme_provider_1.useTheme)();

@@ -43,12 +82,9 @@ const allFiltersFilled = itemsFilter.filter(f3 => f3.filter.filter(f2 => f2.items.filter(f => (f.filterValue === '' && (f.selectedComparison ? f.selectedComparison.value : '-').indexOf('IS') !== 0) || !f.selectedComparison || !f.selectedFilter).length > 0).length > 0).length === 0;

react_1.default.createElement(react_1.Fragment, null, itemsFilter.map(({ id, filter }, idx) => (react_1.default.createElement(FilterItem_1.FilterItem, { key: `filter-${id}`, id: id, filter: filter, allowRemove: itemsFilter.length > 0 })))),
react_1.default.createElement("div", { className: "flex justify-between py-4" },
react_1.default.createElement("div", { className: (0, classnames_1.default)("flex items-center cursor-pointer", { 'invisible': !allFiltersFilled }) },
react_1.default.createElement(v3_buttons_toolbar_button_1.ToolbarButton, { iconName: 'plus', onClick: addNewBlockFilter, children: 'Add filter',
// bgColor={"bg-teal-50 dark:bg-gray-800"}
textColor: "text-teal-500 dark:text-teal-400" })),
react_1.default.createElement("div", { className: 'flex gap-4' },
react_1.default.createElement(v3_buttons_toolbar_button_1.ToolbarButton, { iconName: 'filter', onClick: onFilter, children: 'Filter', className: (0, classnames_1.default)({ 'hidden': !allFiltersFilled }), bgColor: "bg-sky-50 dark:bg-gray-800", textColor: "text-sky-500 dark:text-sky-400" }),
react_1.default.createElement(v3_buttons_toolbar_button_1.ToolbarButton, { iconName: 'trash', onClick: clearBlockFilter, children: 'Clear', className: (0, classnames_1.default)({ 'hidden': itemsFilter.length === 0 }), bgColor: "bg-white dark:bg-gray-800", textColor: "text-red-500 dark:text-red-400" })))));
react_1.default.createElement(crm_ui_1.Window.list.filter.toolbar.actionBar, { onAddFilter: allFiltersFilled ? addNewBlockFilter : undefined, onFilter: allFiltersFilled ? onFilter : undefined, onClear: itemsFilter.length > 0 ? clearBlockFilter : undefined, onSave: itemsFilter.length > 0 ? createSavedSearch : undefined, saved: savedFilters.length > 0 ? {
list: savedFilters,
onFilter: setItemsFilter,
onRemove: removeFavourite,
} : undefined })));
};
exports.Filter = Filter;
//# sourceMappingURL=Filter.js.map

@@ -165,3 +165,3 @@ "use strict";

} },
react_1.default.createElement(Filter_1.Filter, { addNewBlockFilter: addNewBlockFilter, itemsFilter: itemsFilter, clearBlockFilter: clearBlockFilter, onFilter: () => onFilter(itemsFilter) })),
react_1.default.createElement(Filter_1.Filter, { addNewBlockFilter: addNewBlockFilter, itemsFilter: itemsFilter, setItemsFilter: setItemsFilter, clearBlockFilter: clearBlockFilter, onFilter: () => onFilter(itemsFilter), schema: schema })),
react_1.default.createElement(ModalFilter_1.ModalFilter, { isModal: isModal, onChangeIsModal: onChangeIsModal, changeModalSearch: onChangeModalSearch, modalSearch: modalSearchValue, onChooseFilter: onChooseFilter, modalProperties: modalProperties, schema: schema })));

@@ -168,0 +168,0 @@ }

{
"name": "@newageerp/v3.toolbar.filter-container",
"version": "0.2.69",
"version": "0.2.70",
"homepage": "https://bit.dev/newageerp/v3/toolbar/filter-container",

@@ -9,3 +9,3 @@ "main": "dist/index.js",

"name": "v3/toolbar/filter-container",
"version": "0.2.69"
"version": "0.2.70"
},

@@ -16,10 +16,10 @@ "dependencies": {

"core-js": "^3.0.0",
"@newageerp/v3.hooks.use-u-request": "2.4.28",
"@newageerp/v3.layout.theme-provider": "0.2.7",
"@newageerp/v3.templates.templates-core": "2.4.27",
"@newageerp/v3.buttons.toolbar-button": "2.4.32",
"@newageerp/v3.layout.theme-provider": "0.2.7",
"@newageerp/v3.form.field-date": "2.4.14",
"@newageerp/v3.form.field-date": "2.4.15",
"@newageerp/v3.form.field-input": "2.4.8",
"@newageerp/v3.form.field-select": "2.4.11",
"@newageerp/v3.hooks.use-u-request": "2.4.28",
"@newageerp/v3.popups.popup": "2.4.8",
"@newageerp/v3.templates.templates-core": "2.4.27"
"@newageerp/v3.popups.popup": "2.4.8"
},

@@ -35,3 +35,3 @@ "devDependencies": {

"peerDependencies": {
"@newageerp/crm-ui": ">=0.1.53"
"@newageerp/crm-ui": ">=0.1.56"
},

@@ -38,0 +38,0 @@ "license": "SEE LICENSE IN LICENSE",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet