-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added screen of work status and modified the type of work screen to s…
…elect work status and type of photos
- Loading branch information
1 parent
431d8f8
commit 745a5e4
Showing
16 changed files
with
379 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, {useState} from "react"; | ||
|
||
|
||
interface MultipleSelectorProps { | ||
options: string[] | ||
selected: Set<string> | ||
onSelectionChanged?: (selected: Set<string>) => void | ||
} | ||
|
||
export const MultipleSelector: React.FC<MultipleSelectorProps> = (props) => { | ||
|
||
const {options, selected, onSelectionChanged} = props | ||
const [state, setState] = useState({selected: selected}) | ||
|
||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const index = event.target.name | ||
const currSelected = toggleIndex(index) | ||
if (onSelectionChanged) { | ||
onSelectionChanged(currSelected) | ||
} | ||
setState((prevState) => { | ||
return {...prevState, selected: currSelected} | ||
}) | ||
} | ||
|
||
const toggleIndex = (index: string): Set<string> => { | ||
let currSelected = new Set(state.selected) | ||
if (currSelected.has(index)) { | ||
currSelected.delete(index) | ||
} else { | ||
currSelected.add(index) | ||
} | ||
return currSelected | ||
} | ||
|
||
|
||
return ( | ||
<div> | ||
{options.map((option, index) => { | ||
return ( | ||
<div className="block" key={index}> | ||
<label className="checkbox"> | ||
<input type="checkbox" name={index.toString()} | ||
checked={state.selected.has(index.toString())} | ||
onChange={handleChange}/> | ||
{" " + option} | ||
</label> | ||
</div> | ||
|
||
) | ||
} | ||
)} | ||
</div> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from "react"; | ||
|
||
interface TagListProps { | ||
tags: string[] | ||
} | ||
|
||
export const TagList: React.FC<TagListProps> = (props) => { | ||
|
||
const {tags} = props | ||
|
||
return ( | ||
<div> | ||
<div className="tags"> | ||
{tags.map((tag, index) => { | ||
return <span className="tag is-medium is-rounded is-info" key={index}>{tag}</span> | ||
})} | ||
</div> | ||
</div> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export type TypeWork = { | ||
flag?: number, | ||
name: "" | ||
name: "", | ||
status_list: number[] | ||
} |
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,18 @@ | ||
import React from "react"; | ||
import {useStores} from "../core/contexts/UseStores"; | ||
import {ListTypePhoto} from "../components/lists/ListTypePhoto"; | ||
|
||
export const TypePhotoScreen: React.FC<any> = (props) => { | ||
const {typePhotoStore} = useStores() | ||
typePhotoStore.loadTypePhotoList() | ||
|
||
return ( | ||
<div className="columns"> | ||
<div className="column is-two-thirds"> | ||
<ListTypePhoto/> | ||
</div> | ||
<div className="column"> | ||
</div> | ||
</div> | ||
) | ||
} |
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,60 @@ | ||
import {observer} from "mobx-react"; | ||
import React from "react"; | ||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; | ||
import {faEdit} from "@fortawesome/free-solid-svg-icons"; | ||
import {useStores} from "../../core/contexts/UseStores"; | ||
import TypePhotoSelect from "./TypePhotoSelect"; | ||
|
||
export const TypePhotoBox: React.FC<any> = observer((props) => { | ||
const {viewStore, typePhotoStore, typeWorkStore} = useStores() | ||
const selectedTypeWork = typeWorkStore.selectedTypeWork | ||
|
||
const handleOnEditClicked = async () => { | ||
await typePhotoStore.loadTypePhotoList() | ||
const options = typePhotoStore.typePhotoList | ||
let mSelected = [] | ||
let workStatusSelect = { | ||
title: "Selecionar tipos de fotos", | ||
confirmButton: "Selecionar", | ||
onConfirmClick: () => { | ||
|
||
}, | ||
contentView: | ||
<TypePhotoSelect | ||
options={options.map(option => option.name)} | ||
onChangeSelectedOptions={(selectedOptions) => { | ||
mSelected = selectedOptions | ||
}} | ||
/> | ||
} | ||
viewStore.setViewInModal(workStatusSelect) | ||
} | ||
|
||
return ( | ||
<div className="panel"> | ||
<div className="panel-heading"> | ||
<nav className="level"> | ||
<div className="level-left"> | ||
<div className="level-item"> | ||
Tipos de fotos | ||
</div> | ||
</div> | ||
<div className="level-right"> | ||
<div className="level-item"> | ||
<button className="button is-info" onClick={handleOnEditClicked} | ||
disabled={!selectedTypeWork}> | ||
<span className="icon is-small"> | ||
<FontAwesomeIcon icon={faEdit}/> | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
</nav> | ||
</div> | ||
<div className="panel-block" style={{ | ||
minHeight: 250, | ||
}}> | ||
</div> | ||
</div> | ||
) | ||
}) |
8 changes: 4 additions & 4 deletions
8
...dashboard/src/views/TypePhotoCRUDView.tsx → ...src/views/typePhoto/TypePhotoCRUDView.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
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,47 @@ | ||
import {BaseCRUDView} from "../../components/base/BaseCRUDView"; | ||
import {MultipleSelector} from "../../components/form/MultipleSelector"; | ||
import React from "react"; | ||
|
||
interface TypePhotoSelectProps { | ||
options: string[] | ||
onChangeSelectedOptions?: (selectedOptions: number[]) => void | ||
} | ||
|
||
const initialState = { | ||
selectedOptions: [] | ||
} | ||
|
||
type TypePhotoSelectState = typeof initialState | ||
|
||
export default class TypePhotoSelect extends BaseCRUDView<TypePhotoSelectProps, TypePhotoSelectState>{ | ||
|
||
isValid(): boolean { | ||
let valid = true | ||
Object.values(this.state).forEach(value => { | ||
if (!value) { | ||
valid = false | ||
} | ||
}) | ||
return valid | ||
} | ||
|
||
handleWorkChange = (selected: Set<string>) => { | ||
if (this.props.onChangeSelectedOptions) { | ||
this.props.onChangeSelectedOptions([selected.values()].map(value => { | ||
return value as unknown as number; | ||
})) | ||
} | ||
} | ||
|
||
onChange = (value: TypePhotoSelectState) => { | ||
|
||
} | ||
|
||
render() { | ||
return( | ||
<div className="container has-text-left"> | ||
<MultipleSelector options={this.props.options} selected={new Set<string>()} onSelectionChanged={this.handleWorkChange}/> | ||
</div> | ||
) | ||
} | ||
} |
Oops, something went wrong.