-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1062 from sebastianbarry/rewrite-infinite-scroll-…
…filters ✍️📂 Rewrite Infinite Scroll Filters (Multilabel + Enketo)
- Loading branch information
Showing
8 changed files
with
105 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* The general structure of this code is that all the timeline information for | ||
* a particular day is retrieved from the Timeline factory and put into the scope. | ||
* For best performance, all data should be loaded into the in-memory timeline, | ||
* and in addition to writing to storage, the data should be written to memory. | ||
* All UI elements should only use $scope variables. | ||
*/ | ||
|
||
import i18next from "i18next"; | ||
import { getAngularService } from "../../angular-react-helper"; | ||
|
||
const unlabeledCheck = (t) => { | ||
try { | ||
const EnketoTripButtonService = getAngularService("EnketoTripButtonService"); | ||
const etbsSingleKey = EnketoTripButtonService.SINGLE_KEY; | ||
return typeof t.userInput[etbsSingleKey] === 'undefined'; | ||
} | ||
catch (e) { | ||
console.log("Error in retrieving EnketoTripButtonService: ", e); | ||
} | ||
} | ||
|
||
const UNLABELED = { | ||
key: "unlabeled", | ||
text: i18next.t("diary.unlabeled"), | ||
filter: unlabeledCheck | ||
} | ||
|
||
const TO_LABEL = { | ||
key: "to_label", | ||
text: i18next.t("diary.to-label"), | ||
filter: unlabeledCheck | ||
} | ||
|
||
export const configuredFilters = [ | ||
TO_LABEL, | ||
UNLABELED | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* The general structure of this code is that all the timeline information for | ||
* a particular day is retrieved from the Timeline factory and put into the scope. | ||
* For best performance, all data should be loaded into the in-memory timeline, | ||
* and in addition to writing to storage, the data should be written to memory. | ||
* All UI elements should only use $scope variables. | ||
*/ | ||
|
||
import i18next from "i18next"; | ||
|
||
const unlabeledCheck = (t) => { | ||
return t.INPUTS | ||
.map((inputType, index) => !t.userInput[inputType]) | ||
.reduce((acc, val) => acc || val, false); | ||
} | ||
|
||
const invalidCheck = (t) => { | ||
const retVal = | ||
(t.userInput['MODE'] && t.userInput['MODE'].value === 'pilot_ebike') && | ||
(!t.userInput['REPLACED_MODE'] || | ||
t.userInput['REPLACED_MODE'].value === 'pilot_ebike' || | ||
t.userInput['REPLACED_MODE'].value === 'same_mode'); | ||
return retVal; | ||
} | ||
|
||
const toLabelCheck = (trip) => { | ||
if (trip.expectation) { | ||
console.log(trip.expectation.to_label) | ||
return trip.expectation.to_label && unlabeledCheck(trip); | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
const UNLABELED = { | ||
key: "unlabeled", | ||
text: i18next.t("diary.unlabeled"), | ||
filter: unlabeledCheck, | ||
width: "col-50" | ||
} | ||
|
||
const INVALID_EBIKE = { | ||
key: "invalid_ebike", | ||
text: i18next.t("diary.invalid-ebike"), | ||
filter: invalidCheck | ||
} | ||
|
||
const TO_LABEL = { | ||
key: "to_label", | ||
text: i18next.t("diary.to-label"), | ||
filter: toLabelCheck, | ||
width: "col-50" | ||
} | ||
|
||
export const configuredFilters = [ | ||
TO_LABEL, | ||
UNLABELED | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters