-
Notifications
You must be signed in to change notification settings - Fork 3
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 #977 from digitalfabrik/900-add-field-nuernberg-pa…
…ss-id 900: add field nuernberg pass id & add new pdf template
- Loading branch information
Showing
22 changed files
with
321 additions
and
174 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 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 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
69 changes: 69 additions & 0 deletions
69
administration/src/cards/extensions/NuernbergPassIdExtension.tsx
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,69 @@ | ||
import { FormGroup, InputGroup, Intent } from '@blueprintjs/core' | ||
|
||
import { Extension } from './extensions' | ||
|
||
const nuernbergPassIdNumberLength = 10 | ||
|
||
type NuernbergPassIdState = { nuernbergPassId: number } | ||
class NuernbergPassIdExtension extends Extension<NuernbergPassIdState, null> { | ||
public readonly name = NuernbergPassIdExtension.name | ||
|
||
setInitialState() {} | ||
createForm(onUpdate: () => void) { | ||
return ( | ||
<FormGroup | ||
label='Nürnberg-Pass-ID' | ||
labelFor='nuernberg-pass-id-input' | ||
intent={this.isValid() ? undefined : Intent.DANGER}> | ||
<InputGroup | ||
id='nuernberg-pass-id-input' | ||
placeholder='12345678' | ||
intent={this.isValid() ? undefined : Intent.DANGER} | ||
value={this.state?.nuernbergPassId.toString() ?? ''} | ||
maxLength={nuernbergPassIdNumberLength} | ||
onChange={event => { | ||
const value = event.target.value | ||
if (value.length > nuernbergPassIdNumberLength) { | ||
return | ||
} | ||
|
||
const parsedNumber = Number.parseInt(value) | ||
|
||
if (isNaN(parsedNumber)) { | ||
this.state = null | ||
onUpdate() | ||
return | ||
} | ||
|
||
this.state = { | ||
nuernbergPassId: parsedNumber, | ||
} | ||
onUpdate() | ||
}} | ||
/> | ||
</FormGroup> | ||
) | ||
} | ||
|
||
causesInfiniteLifetime() { | ||
return false | ||
} | ||
|
||
isValid() { | ||
return ( | ||
this.state !== null && | ||
this.state.nuernbergPassId > 0 && | ||
this.state.nuernbergPassId < 10 ** nuernbergPassIdNumberLength | ||
) | ||
} | ||
|
||
fromString(state: string) { | ||
this.state = { nuernbergPassId: parseInt(state, 10) } | ||
} | ||
|
||
toString() { | ||
return this.state ? `${this.state.nuernbergPassId}` : '' | ||
} | ||
} | ||
|
||
export default NuernbergPassIdExtension |
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,13 @@ | ||
export type Coordinates = { | ||
x: number | ||
y: number | ||
} | ||
|
||
export function mmToPt(mm: number) { | ||
return (mm / 25.4) * 72 | ||
} | ||
|
||
export type PdfElement<ConfigOptions extends Record<string, any>, DynamicOptions extends Record<string, any>> = ( | ||
options: ConfigOptions, | ||
dynamicOptions: DynamicOptions | ||
) => void |
Oops, something went wrong.