-
-
Notifications
You must be signed in to change notification settings - Fork 735
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for image orientation filter
- Loading branch information
Showing
9 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package models | ||
|
||
type OrientationEnum string | ||
|
||
const ( | ||
OrientationLandscape OrientationEnum = "Landscape" | ||
OrientationPortrait OrientationEnum = "Portrait" | ||
OrientationSquare OrientationEnum = "Square" | ||
) | ||
|
||
func (e OrientationEnum) IsValid() bool { | ||
switch e { | ||
case OrientationLandscape, OrientationPortrait, OrientationSquare: | ||
return true | ||
} | ||
return false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { orientationStrings } from "src/utils/orientation"; | ||
import { CriterionType } from "../types"; | ||
import { CriterionOption, StringCriterion } from "./criterion"; | ||
import { CriterionModifier } from "../../../core/generated-graphql"; | ||
|
||
export class OrientationCriterion extends StringCriterion { | ||
protected toCriterionInput(): string { | ||
return this.value; | ||
} | ||
} | ||
|
||
class BaseOrientationCriterionOption extends CriterionOption { | ||
constructor(value: CriterionType) { | ||
super({ | ||
messageID: value, | ||
type: value, | ||
modifierOptions: [], | ||
options: orientationStrings, | ||
defaultModifier: CriterionModifier.Equals, | ||
makeCriterion: () => new OrientationCriterion(this), | ||
}); | ||
} | ||
} | ||
|
||
export const OrientationCriterionOption = new BaseOrientationCriterionOption( | ||
"orientation" | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { OrientationEnum } from "src/core/generated-graphql"; | ||
|
||
const stringOrientationMap = new Map<string, OrientationEnum>([ | ||
["Landscape", OrientationEnum.Landscape], | ||
["Portrait", OrientationEnum.Portrait], | ||
["Square", OrientationEnum.Square], | ||
]); | ||
|
||
export const stringToOrientation = ( | ||
value?: string | null, | ||
caseInsensitive?: boolean | ||
) => { | ||
if (!value) { | ||
return undefined; | ||
} | ||
|
||
const ret = stringOrientationMap.get(value); | ||
if (ret || !caseInsensitive) { | ||
return ret; | ||
} | ||
|
||
const asUpper = value.toUpperCase(); | ||
const foundEntry = Array.from(stringOrientationMap.entries()).find((e) => { | ||
return e[0].toUpperCase() === asUpper; | ||
}); | ||
|
||
if (foundEntry) { | ||
return foundEntry[1]; | ||
} | ||
}; | ||
|
||
export const orientationStrings = Array.from(stringOrientationMap.keys()); |