@@ -3,7 +3,8 @@ import NewDialog from "./new-dialog.js";
33
44import SearchIcon from "@material-ui/icons/Search" ;
55import { withTranslation } from "react-i18next" ;
6- import "./form-data.css" ;
6+
7+ import "../form-data/form-data.css" ;
78
89import CustomMenuService from "./../../../services/custom-menu.service" ;
910
@@ -37,8 +38,7 @@ class AgencyFormData extends Component {
3738 const item = menuItems [ activeItem ] ;
3839 const data = { }
3940 data [ activeItem ] = item . data ;
40- menuService . updateMenus ( menuId , { $set : data } ) . then ( ( result ) => {
41-
41+ menuService . updateMenus ( menuId , { $set : data } ) . then ( ( result ) => {
4242 } ) . catch ( ( err ) => {
4343
4444 } ) ;
@@ -61,6 +61,21 @@ class AgencyFormData extends Component {
6161 }
6262 }
6363
64+
65+ deleteItem = ( tab , itemIndex ) => {
66+ const { menuItems } = this . state ;
67+ const item = menuItems [ tab ] ;
68+ if ( item && item . data && itemIndex < item . data . length ) {
69+ item . data . splice ( itemIndex , 1 ) ;
70+ this . setState ( {
71+ menuItems : menuItems ,
72+ dialogDisplayed : false
73+ } ) ;
74+ this . saveData ( ) ;
75+ }
76+ }
77+
78+
6479 changeCurrentTab = ( tab ) => {
6580 this . setState ( { activeItem : tab } ) ;
6681 }
@@ -97,80 +112,80 @@ class AgencyFormData extends Component {
97112 render ( ) {
98113
99114 const { menuItems, dialogDisplayed, activeItem } = this . state ;
100- const { t, agency } = this . props ;
101-
115+ const { t } = this . props ;
102116 const item = menuItems [ activeItem ] ;
103117
104118 return < div className = "agency-form-data flex-row full-view" >
105119 < div className = "flex-column justify-between form-content-menu" >
106- < div onClick = { ( ) => this . changeCurrentTab ( "activities" ) } className = { "form-menu-item" + ( activeItem == "activities" || activeItem == "gear" || activeItem == "fishery" ? " active-form-menu-item" : "" ) } >
120+ < div onClick = { ( ) => this . changeCurrentTab ( "activities" ) } className = { "form-menu-item" + ( activeItem === "activities" || activeItem === "gear" || activeItem = == "fishery" ? " active-form-menu-item" : "" ) } >
107121 Activity
108122 </ div >
109- < div onClick = { ( ) => this . changeCurrentTab ( "activities" ) } className = { "form-menu-item sub-item" + ( activeItem == "activities" ? " active-form-menu-item" : "" ) } >
123+ < div onClick = { ( ) => this . changeCurrentTab ( "activities" ) } className = { "form-menu-item sub-item" + ( activeItem === "activities" ? " active-form-menu-item" : "" ) } >
110124 Activity
111125 </ div >
112- < div onClick = { ( ) => this . changeCurrentTab ( "species" ) } className = { "form-menu-item sub-item" + ( activeItem == "species" ? " active-form-menu-item" : "" ) } >
126+ < div onClick = { ( ) => this . changeCurrentTab ( "species" ) } className = { "form-menu-item sub-item" + ( activeItem === "species" ? " active-form-menu-item" : "" ) } >
113127 Fishery
114128 </ div >
115- < div onClick = { ( ) => this . changeCurrentTab ( "gear" ) } className = { "form-menu-item sub-item" + ( activeItem == "gear" ? " active-form-menu-item" : "" ) } >
129+ < div onClick = { ( ) => this . changeCurrentTab ( "gear" ) } className = { "form-menu-item sub-item" + ( activeItem === "gear" ? " active-form-menu-item" : "" ) } >
116130 Gear
117131 </ div >
118- < div onClick = { ( ) => this . changeCurrentTab ( "fisheries" ) } className = { "form-menu-item" + ( activeItem == "fisheries" ? " active-form-menu-item" : "" ) } >
132+ < div onClick = { ( ) => this . changeCurrentTab ( "fisheries" ) } className = { "form-menu-item" + ( activeItem === "fisheries" ? " active-form-menu-item" : "" ) } >
119133 Catch
120134 </ div >
121- < div onClick = { ( ) => this . changeCurrentTab ( "emsTypes" ) } className = { "form-menu-item" + ( activeItem == "emsTypes" ? " active-form-menu-item" : "" ) } >
135+ < div onClick = { ( ) => this . changeCurrentTab ( "emsTypes" ) } className = { "form-menu-item" + ( activeItem === "emsTypes" ? " active-form-menu-item" : "" ) } >
122136 EMS
123137 </ div >
124- < div onClick = { ( ) => this . changeCurrentTab ( "ports" ) } className = { "form-menu-item" + ( activeItem == "ports" ? " active-form-menu-item" : "" ) } >
138+ < div onClick = { ( ) => this . changeCurrentTab ( "ports" ) } className = { "form-menu-item" + ( activeItem === "ports" ? " active-form-menu-item" : "" ) } >
125139 Vessel flag State
126140 </ div >
127- < div onClick = { ( ) => this . changeCurrentTab ( "violationCodes" ) } className = { "form-menu-item" + ( activeItem == "violationCodes" ? " active-form-menu-item" : "" ) } >
141+ < div onClick = { ( ) => this . changeCurrentTab ( "violationCodes" ) } className = { "form-menu-item" + ( activeItem === "violationCodes" ? " active-form-menu-item" : "" ) } >
128142 Violation Codes
129143 </ div >
130- < div onClick = { ( ) => this . changeCurrentTab ( "violationDescriptions" ) } className = { "form-menu-item" + ( activeItem == "violationDescriptions" ? " active-form-menu-item" : "" ) } >
144+ < div onClick = { ( ) => this . changeCurrentTab ( "violationDescriptions" ) } className = { "form-menu-item" + ( activeItem === "violationDescriptions" ? " active-form-menu-item" : "" ) } >
131145 Violations Descriptions
132146 </ div >
133147 </ div >
134148 { item && item . data && item . data . length
135149 ?
136- < div className = "flex-column form-content form-search" >
137- < div className = "flex-row justify-between align-center form-search-panel" >
138- < div >
139- < h3 > { item . data . length + ' ' + item . title } </ h3 >
140- </ div >
141- < div className = "form-search-field" >
142- < div className = "search-icon" >
143- < SearchIcon />
150+ < div className = "flex-column form-content form-search" >
151+ < div className = "flex-row justify-between align-center form-search-panel" >
152+ < div >
153+ < h3 > { item . data . length + ' ' + item . title } </ h3 >
144154 </ div >
145- < input
146- className = "search-field"
147- type = "search"
148- placeholder = "Search Species"
149- > </ input >
155+ < div className = "form-search-field" >
156+ < div className = "search-icon" >
157+ < SearchIcon />
158+ </ div >
159+ < input
160+ className = "search-field"
161+ type = "search"
162+ placeholder = { t ( "BUTTONS.SEARCH" ) + " " + item . title }
163+ > </ input >
164+ </ div >
165+ < button className = "blue-btn" onClick = { this . showDialog } >
166+ { item . btn }
167+ </ button >
168+ </ div >
169+ < div className = "form-checkbox-list" >
170+ { item . data . map ( ( item , ind ) => (
171+ < div
172+ className = "flex-row align-center form-info-box"
173+ key = { ind }
174+ >
175+ < input className = "check-item" type = "checkbox" />
176+ < span className = "name" > { item } </ span >
177+ < span className = "inline-btn" onClick = { ( ) => this . deleteItem ( activeItem , ind ) } > { t ( "BUTTONS.DELETE" ) } </ span >
178+ </ div >
179+ ) ) }
180+ </ div >
150181 </ div >
151- < button className = "blue-btn" onClick = { this . showDialog } >
152- { item . btn }
153- </ button >
154- </ div >
155- < div className = "form-checkbox-list" >
156- { item . data . map ( ( item , ind ) => (
157- < div
158- className = "flex-row align-center form-info-box"
159- key = { ind }
160- >
161- < input className = "check-item" type = "checkbox" />
162- { item }
163- </ div >
164- ) ) }
165- </ div >
166- </ div >
167- : < div className = "flex-column full-view align-center form-content form-empty" >
168- < div className = "title flex-row align-center justify-center" > No { item . title } </ div >
169- < button className = "blue-btn" onClick = { this . showDialog } >
170- { item . btn }
171- </ button >
172- </ div >
173- }
182+ : < div className = "flex-column full-view align-center form-content form-empty" >
183+ < div className = "title flex-row align-center justify-center" > No { item . title } </ div >
184+ < button className = "blue-btn" onClick = { this . showDialog } >
185+ { item . btn }
186+ </ button >
187+ </ div >
188+ }
174189 { dialogDisplayed && < NewDialog onApply = { this . dialogClosed } title = { item . title } lineText = { item . btn } > </ NewDialog > }
175190 </ div > ;
176191 }
0 commit comments