Skip to content

Commit

Permalink
Dev (#642)
Browse files Browse the repository at this point in the history
* update ky, fix ag to svelte example, RestDataApi will look for q and do stringify if its an object

* Fixed quick search

* Fixed search

* refactor select2 so uses same fomratter for displayFields

* comment out select tests since we dont support

* get tests working for jest and ts. revamp truthy and empty

* add jest to the checks

* remove the setup for now

* get jest tests working and move critical tests in, all tests are in __tests__

* Select fixes (#643)

* Fixed select with complex dataApiParams

* Lint fix

* esm to get mockserver working with imports

* reverted ts, to slow.

* fix and cleanup the listctrl dep (#644)

* fix and cleanup the listctrl dep

* should have a property that we pass to GRidCtrl for contextMenuClickAction

* pass everything through with the gridOpts

* fixed showSearchForm

* more clean up

* cleanup to get rid of extendFilters

* removed a bunch of console logs

* add init search to config

* Filtering refactoring

Co-authored-by: alexeyzvegintcev <alexey.zvegintcev@sysgears.com>

* Grid remove listctrl dep (#645)

* fix and cleanup the listctrl dep

* should have a property that we pass to GRidCtrl for contextMenuClickAction

* pass everything through with the gridOpts

* fixed showSearchForm

* more clean up

* cleanup to get rid of extendFilters

* removed a bunch of console logs

* add init search to config

* Filtering refactoring

* get sort squared away

* more lodash cleanup

* fix for es6

* rename to restrictSearch

* add start of the DataQuery class

Co-authored-by: alexeyzvegintcev <alexey.zvegintcev@sysgears.com>

* Grid remove listctrl dep (#646)

* fix and cleanup the listctrl dep

* should have a property that we pass to GRidCtrl for contextMenuClickAction

* pass everything through with the gridOpts

* fixed showSearchForm

* more clean up

* cleanup to get rid of extendFilters

* removed a bunch of console logs

* add init search to config

* Filtering refactoring

* get sort squared away

* more lodash cleanup

* fix for es6

* rename to restrictSearch

* add start of the DataQuery class

Co-authored-by: alexeyzvegintcev <alexey.zvegintcev@sysgears.com>

* fixed foo bar

* Grid fixes (#648)

* Fixed cors issue for grids

* Grid actions without listCtrl import

* Custom toolbar actions

* Fixed typo

Co-authored-by: alexeyzvegintcev <alexey.zvegintcev@sysgears.com>

Co-authored-by: alexeyzvegintcev <alexey.zvegintcev@sysgears.com>
  • Loading branch information
basejump and alexeyzvegintcev authored Dec 15, 2021
1 parent 7e2e4a8 commit 86dd8a8
Show file tree
Hide file tree
Showing 83 changed files with 1,437 additions and 956 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
paths: [ './node_modules' ]

- run: make lint
- run: make jest
- run: make test.karma
- run: make test.jasmine
- run: make build.demo
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include $(SHIPKIT_MAKEFILES)/circle.make
export BOT_EMAIL ?= 9cibot@9ci.com
karma.sh = npx karma
lint.sh = npx eslint
jest.sh = npx jest

# --- standard base build ----

Expand All @@ -26,7 +27,7 @@ install: node_modules
check: install lint test

## runs both karma and jasmine tests
test: test.karma test.jasmine
test: jest test.karma test.jasmine

## runs karma tests
test.karma:
Expand All @@ -36,6 +37,10 @@ test.karma:
test.jasmine:
$(karma.sh) start tests/karma-jasmine.conf.js --single-run --no-auto-watch --no-sandbox $$*

## runs jasmine tests
jest:
$(jest.sh)

## runs eslint
lint:
$(lint.sh) src/
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var configData = {
base_url:"http://localhost:3002/",
base_url:"http://0.0.0.0:3002/",
foo:"bar"
}
3 changes: 3 additions & 0 deletions examples/demo/mocker/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//esm allows imports to work with node
require = require("esm")(module);

const delay = require('mocker-api/utils/delay')
// const _ = require('lodash')
const yaml = require('js-yaml')
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/public/data/CustomerConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gridOptions:
- { name: num, width: 30 }
- { name: name, formatter: editActionLink }
- { name: city, width: 100 }
- { name: state, width: 60 }
- { name: location.state, width: 60 }
- { name: postalCode, label: Zip, width: 60 }
- { name: country, width: 60 }
# sortname: name
Expand Down
35 changes: 35 additions & 0 deletions examples/demo/public/data/Customers.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"id": 1,
"name": "Rhynoodle",
"num": "RH0143",
"location": {
"street": "04828 Mcguire Alley",
"city": "Sacramento",
"state": "CA",
"postalCode": 95833,
"country": "US"
},
"street": "04828 Mcguire Alley",
"city": "Sacramento",
"state": "CA",
Expand All @@ -14,6 +21,13 @@
"id": 2,
"name": "Yodo",
"num": "YO7612",
"location": {
"street": "405 Old Shore Avenue",
"city": "Merritt",
"state": "BC",
"postalCode": "V1K",
"country": "CA"
},
"street": "405 Old Shore Avenue",
"city": "Merritt",
"state": "BC",
Expand All @@ -25,6 +39,13 @@
"id": 3,
"name": "Omba",
"num": "OM3054",
"location": {
"street": "8 Charing Cross Circle",
"city": "Niños Heroes",
"state": "OAX",
"postalCode": 68145,
"country": "MX"
},
"street": "8 Charing Cross Circle",
"city": "Niños Heroes",
"state": "OAX",
Expand All @@ -36,6 +57,13 @@
"id": 4,
"name": "Gabcube",
"num": "GA8966",
"location": {
"street": "55 Warbler Street",
"city": "Colorado Springs",
"state": "CO",
"postalCode": 80945,
"country": "US"
},
"street": "55 Warbler Street",
"city": "Colorado Springs",
"state": "CO",
Expand All @@ -47,6 +75,13 @@
"id": 5,
"name": "Voonder",
"num": "VO3537",
"location": {
"street": "4402 Summer Ridge Drive",
"city": "Maskinongé",
"state": "QC",
"postalCode": "T7A",
"country": "CA"
},
"street": "4402 Summer Ridge Drive",
"city": "Maskinongé",
"state": "QC",
Expand Down
15 changes: 14 additions & 1 deletion examples/demo/src/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@ import appName from './app.module'
import './config.router'
import appState from 'angle-grinder/src/tools/AppState'
import {setConfig} from 'angle-grinder/src/tools/AppConfig'
import {setClientConfig} from "angle-grinder/src/dataApi/kyClient";
import {setClientConfig} from "angle-grinder/src/dataApi/kyApi";

const app = angular.module(appName)
// export default app.name

app.run(function($rootScope, $state, $stateParams) {

// window.onbeforeunload = function(){
// sessionStorage.setItem("origin", window.location.href);
// }

// window.onload = function(){
// console.log("************window.location.href", window.location.href)
// if(window.location.href == sessionStorage.getItem("origin")){
// console.log("************clearing storage", window.location.href)
// sessionStorage.clear();
// }
// }

'ngInject';
// Set the ui-router state vars to global root to access them from any scope
$rootScope.$state = $state
Expand Down
3 changes: 2 additions & 1 deletion examples/demo/src/controls/select-rest/select-rest.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<p>LEGACY WAY OF DOING IT WITH AJAX, PREFER USING dataApiKey</p>
<form name="selRestForm" ag-form is-horizontal>

<ag-select-rest select-options="{ multiple: true, minimumInputLength: 1}"
<ag-select-rest select-options="{ multiple: true, minimumInputLength: 1, closeOnSelect:false}"
ng-model="$ctrl.vm.multipleCustomer"
url="/api/customer/picklist">
</ag-select-rest>
Expand Down
31 changes: 13 additions & 18 deletions examples/demo/src/controls/select/basic/comp.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,31 @@
</div>
</div>

<div class="columns is-mobile">
<ag-label>Basic Select2</ag-label>
<div class="field column is-grouped">
<div class="control is-expanded">
<input class="input" ng-model="$ctrl.vm.day"
placeholder="select a day" ui-select2 ui-select2-data="['Mon','Tue','Wed','Thu','Fri','Sat','Sun']">
</div>
<div class="control is-expanded">
<input class="input" ng-model="$ctrl.vm.color"
ui-select2="{ allowClear: false, placeholder: 'select a color', data:['red','green', 'blue']}">
</div>
</div>
</div>
<ag-select name="agsel-day" ng-model="$ctrl.vm.day" placeholder="select a day"
select-options="{ data: ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'] }"></ag-select>

<p>using ag-select component</p>
<ag-select name="agSelect" ng-model="$ctrl.vm.agColor" placeholder="select a color" hint="this is a hint"
select-options="{ data: $ctrl.colorData }"></ag-select>

<p>rest data from dataApiKey</p>
<ag-select name="agSelect" ng-model="$ctrl.vm.cust"
select-options="{ dataApiKey: 'customer' }"></ag-select>
<ag-select name="agSelect" ng-model="$ctrl.vm.custParams"

<ag-select name="agSelect-min" ng-model="$ctrl.vm.cust"
select-options="{
multiple: true, dataApiKey: 'customer',
closeOnSelect: false, minimumInputLength: 1,
displayFields:['num', 'name'] }">
</ag-select>

<ag-select name="agSelect" ng-model="$ctrl.vm.custParams"
select-options="{ dataApiKey: 'customer', dataApiParams: {country: 'US'} }"></ag-select>
<ag-select name="agSelect" ng-model="$ctrl.vm.custMulti"
select-options="{ multiple: true, closeOnSelect: false, showSelectAll:true, dataApiKey: 'customer'}"></ag-select>
<ag-select name="agSelect" ng-model="$ctrl.vm.displayFields"
<ag-select name="agSelect" ng-model="$ctrl.vm.displayFields"
select-options="{ multiple: true, closeOnSelect: false, showSelectAll:true, dataApiKey: 'customer', displayFields:['name','num']}"></ag-select>

<p>rest data from promise</p>
<ag-select name="agSelect" ng-model="$ctrl.vm.cust"
<ag-select name="agSelect" ng-model="$ctrl.vm.cust2"
select-options="{ data: $ctrl.custApiData }"></ag-select>
<ag-select name="agSelect" ng-model="$ctrl.vm.custMulti"
select-options="{ multiple: true, closeOnSelect: false, showSelectAll:true, data: $ctrl.custApiData }"></ag-select>
Expand Down
1 change: 1 addition & 0 deletions examples/demo/src/controls/select/selFromData/comp.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<form name="selForm" ag-form >
<ag-select name="singleColor" ng-model="$ctrl.vm.singleColor"
select-options="$ctrl.singleColorOpts">
Expand Down
4 changes: 3 additions & 1 deletion examples/demo/src/grids/customGridList/list/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<gridz ng-if="$ctrl.isConfigured" grid-options="$ctrl.cfg.gridOptions"
toolbar-options="$ctrl.cfg.toolbarOptions"
grid-id="basicGrid"
list-ctrl="$ctrl">
list-ctrl="$ctrl"
init-search="{name: 'yo*'}"
>
</gridz>

<pre ng-cloak class="mt-4">vm: {{$ctrl.vm | json}}</pre>
Expand Down
1 change: 1 addition & 0 deletions examples/demo/src/grids/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const gridsStates = {
}],
resolve: {
apiKey: () => 'customer',
// gridOptions: () => ({multiSort: true}),
notification: () => ({
class: 'is-primary is-light',
text: 'Uses ui-router to send rest apiKey to generic agGridList component'
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/src/store/RestStoreApi.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import RestDataApi from 'angle-grinder/src/dataApi/RestDataApi'
import ky from 'ky'
import kyApi from 'angle-grinder/src/dataApi/kyApi'

function makeDataApi(endpoint){
return new RestDataApi(`${configData.base_url}api/${endpoint}`)
return new RestDataApi(`api/${endpoint}`)
}

/** main holder for api */
Expand All @@ -23,7 +23,7 @@ export class RestStoreApi {
get tag() { return makeDataApi('tag') }

appConfig(configKey) {
return ky.get(`api/appConfig/${configKey}`).json()
return kyApi.ky.get(`api/appConfig/${configKey}`).json()
}

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/grails-demo/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import './app.config'
import './AppCtrl'

import './grids'
import {setClientConfig} from 'angle-grinder/src/dataApi/kyClient'
import {setClientConfig} from 'angle-grinder/src/dataApi/kyApi'

setClientConfig({prefixUrl: 'http://localhost:8080'})
$log.debugEnabled(true)
10 changes: 5 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = {
testMatch: [ "**/__tests__/**/*.[jt]s?(x)"],
testMatch: [ "**/__tests__/**/*.[jt]s?(x)"],
// testMatch: ['<rootDir>/svelte/__tests__/specs/**/*.spec.js'],
transform: {
'^.+\\.m?(j|t)s$': 'babel-jest',
// '^.+\\.svelte$': ['svelte-jester', {preprocess: true}],
'^.+\\.svelte$': ['svelte-jester'],
'^.+\\.svelte$': ['svelte-jester', {preprocess: true}],
// '^.+\\.svelte$': ['svelte-jester'],
/**
* transform any svelte components in node_modules with svelte-jester
*/
Expand All @@ -17,6 +17,6 @@ module.exports = {
},
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
"<rootDir>/jest.setup.js"
// "<rootDir>/jest.setup.js"
]
};
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"dayjs": "^1.10.6",
"dequal": "^2.0.2",
"dotenv": "^10.0.0",
"esm": "^3.2.25",
"fast-safe-stringify": "^2.0.8",
"fastclick": "^1.0.6",
"feather-icons": "^4.28.0",
Expand Down Expand Up @@ -86,6 +87,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.16.0",
"@fullhuman/postcss-purgecss": "^1.3.0",
"@testing-library/jest-dom": "^5.14.1",
"angular-mocks": "1.6.10",
Expand Down
4 changes: 2 additions & 2 deletions src/dataApi/AppConfigApi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import kyApi from './kyClient'
import kyApi from './kyApi'

class LocalCache {
_values = {}
Expand Down Expand Up @@ -45,7 +45,7 @@ export class AppConfigApi {
if (_cache.contains(key)) {
return _cache.get(key)
} else {
const cfg = await kyApi.client.get(key).json()
const cfg = await kyApi.ky.get(key).json()
_cache.set(key, cfg)
return cfg
}
Expand Down
28 changes: 28 additions & 0 deletions src/dataApi/DataQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable no-unused-vars */
import _ from 'lodash'

export default class DataQuery {
//the api endpoint key
dataApi = ""

// the q map or text
q

//qSearch if both using the map criteria in q and a text fuzzy search
qSearch

//initSearch is the initialSearch criteria
initSearch

// when grid is for child or detail data, restrictSearch is what to filter it by,
// for example is showing invoices for customer then restrictSearch might be set to {custId:123}
restrictSearch

//sort map
sort

//page info
max = '20'

page = '1'
}
Loading

0 comments on commit 86dd8a8

Please sign in to comment.