Skip to content

Commit 4886efe

Browse files
authored
Merge pull request #157 from citizennet/davezuch/FBCM-4107/optional-filtering-sorting-typeahead
FBCM-4107 Configurable filtering for Typeahead search results
2 parents e9d7a06 + 1d64ce9 commit 4886efe

File tree

7 files changed

+572
-350
lines changed

7 files changed

+572
-350
lines changed

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
- v1-spago-cache-{{ .Branch }}
2626
- v1-spago-cache
2727

28+
- run:
29+
name: Verify the tests pass
30+
command: make test
31+
2832
- run:
2933
name: Verify the project and all components build successfully
3034
command: make build

Makefile

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ OUTPUT_DIR ?= $(ROOT_DIR)/output
66
PARCEL_DIR ?= $(BUILD_DIR)/parcel
77
RTS_ARGS ?=
88
SRC_DIR ?= $(ROOT_DIR)/src
9+
TEST_DIR ?= $(ROOT_DIR)/test
910
UI_GUIDE_DIR ?= $(ROOT_DIR)/ui-guide
1011

1112
# Variables that we control
@@ -16,6 +17,7 @@ FIND_SRC_FILES_ARGS := \( -name '*.purs' -o -name '*.js' \) -type f
1617
NODE_MODULES := $(ROOT_DIR)/node_modules/.stamp
1718
PACKAGE_JSON := $(ROOT_DIR)/package.json
1819
SRC_FILES := $(shell find $(SRC_DIR) $(FIND_SRC_FILES_ARGS))
20+
TEST_FILES := $(shell find $(TEST_DIR) $(FIND_SRC_FILES_ARGS))
1921
UI_GUIDE_FILES := $(shell find $(UI_GUIDE_DIR) $(FIND_SRC_FILES_ARGS))
2022
YARN_LOCK := $(ROOT_DIR)/yarn.lock
2123

@@ -28,16 +30,29 @@ YARN := cd $(ROOT_DIR) && yarn
2830
$(BUILD_DIR) $(DIST_DIR) $(PARCEL_DIR):
2931
mkdir -p $@
3032

33+
$(BUILD_DIR)/test.js: $(OUTPUT_DIR)/Test.Main/index.js | $(BUILD_DIR)
34+
$(YARN) run purs bundle \
35+
$(RTS_ARGS) \
36+
$(OUTPUT_DIR)/*/*.js \
37+
--main Test.Main \
38+
--module Test.Main \
39+
--output $@
40+
41+
$(BUILD_DIR)/test.out: $(BUILD_DIR)/test.js
42+
node $< | tee $@.tmp # Store output in a temp file in case of a failure.
43+
mv $@.tmp $@ # Move the output where it belongs.
44+
3145
$(DEPS): packages.dhall spago.dhall $(NODE_MODULES) | $(BUILD_DIR)
3246
$(YARN) run spago install $(RTS_ARGS)
3347
touch $@
3448

3549
$(DIST_DIR)/bundled.js: $(OUTPUT_DIR)/Main/index.js
36-
$(YARN) run purs bundle $(OUTPUT_DIR)/*/*.js \
50+
$(YARN) run purs bundle \
51+
$(RTS_ARGS) \
52+
$(OUTPUT_DIR)/*/*.js \
3753
--main Main \
3854
--module Main \
39-
--output $@ \
40-
$(RTS_ARGS)
55+
--output $@
4156

4257
$(DIST_DIR)/index.js: $(OUTPUT_DIR)/Main/index.js
4358
$(YARN) run browserify dist/main.js --outfile $@
@@ -49,6 +64,9 @@ $(NODE_MODULES): $(PACKAGE_JSON) $(YARN_LOCK)
4964
$(OUTPUT_DIR)/Main/index.js: $(SRC_FILES) $(UI_GUIDE_FILES) $(DEPS)
5065
$(YARN) run spago build -p "$(UI_GUIDE_DIR)/**/*.purs" -u "$(RTS_ARGS)"
5166

67+
$(OUTPUT_DIR)/Test.Main/index.js: $(SRC_FILES) $(TEST_FILES) $(DEPS)
68+
$(YARN) run spago build -p "$(TEST_DIR)/Main.purs $(TEST_DIR)/Test/**/*.purs" -u "$(RTS_ARGS)"
69+
5270
.PHONY: build
5371
build: $(BUILD_DEPS)
5472

@@ -65,6 +83,9 @@ clean: $(CLEAN_DEPS)
6583
$(ROOT_DIR)/.spago \
6684
$(ROOT_DIR)/node_modules
6785

86+
.PHONY: test
87+
test: $(BUILD_DIR)/test.out
88+
6889
.PHONY: ui-guide
6990
ui-guide: build-css $(OUTPUT_DIR)/Main/index.js $(NODE_MODULES) | $(PARCEL_DIR)
7091
npx parcel $(DIST_DIR)/parcel.html --out-dir $(PARCEL_DIR) --no-cache

src/Interfaces/Typeahead/Interface.purs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Halogen.VDom.Driver (runUI)
2727
import Html.Renderer.Halogen as Parser
2828
import Network.RemoteData (RemoteData(..))
2929
import Ocelot.Block.ItemContainer (boldMatches)
30-
import Ocelot.Typeahead (Component, Input, Insertable(..), Output(..), Query(..), defRenderContainer, multi, renderMulti, renderSingle, single, component, renderHeaderSearchDropdown, renderSearchDropdown, renderToolbarSearchDropdown)
30+
import Ocelot.Typeahead (Component, Input, Insertable(..), Output(..), Query(..), defFilterFuzzy, defRenderContainer, multi, renderMulti, renderSingle, single, component, renderHeaderSearchDropdown, renderSearchDropdown, renderToolbarSearchDropdown)
3131
import Ocelot.HTML.Properties (css)
3232
import Ocelot.Interface.Utilities (Interface, mkSubscription)
3333
import Partial.Unsafe (unsafePartial)
@@ -247,7 +247,8 @@ single' :: ∀ action item. Eq item => Component action Maybe item Aff
247247
single' = component
248248
{ runSelect: const <<< Just
249249
, runRemove: const (const Nothing)
250-
, runFilter: const
250+
, runFilterFuzzy: defFilterFuzzy
251+
, runFilterItems: const
251252
}
252253

253254
-- DEPRECATED

0 commit comments

Comments
 (0)