@@ -16,6 +16,8 @@ import CheckValues from '../Mixin/Helper/CheckValues.js'
1616import moment from 'moment'
1717import Help from '../Mixin/Html/Help.jsx'
1818import UtilityFunctions from '../Mixin/Edit/UtilityFunctions.js'
19+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
20+ import { faToggleOn , faToggleOff } from '@fortawesome/free-solid-svg-icons'
1921import './style.css'
2022
2123/* global $, subleaseCurrent */
@@ -41,7 +43,9 @@ export default class SubleaseForm extends Base {
4143 'setMoveIn' ,
4244 'setMoveOut' ,
4345 'updateParking' ,
44- 'sendActive'
46+ 'sendActive' ,
47+ 'hideContact' ,
48+ 'showContact'
4549 ]
4650 bindMethods ( methods , this )
4751 }
@@ -244,6 +248,36 @@ export default class SubleaseForm extends Base {
244248 ]
245249 }
246250
251+ hideContact ( ) {
252+ $ . ajax ( {
253+ url : './properties/Sublease/' + this . state . sublease . id ,
254+ data : {
255+ varname : 'hideContact' ,
256+ value : true
257+ } ,
258+ dataType : 'json' ,
259+ type : 'patch' ,
260+ success : function ( ) {
261+ this . setValue ( 'hideContact' , true )
262+ } . bind ( this )
263+ } )
264+ }
265+
266+ showContact ( ) {
267+ $ . ajax ( {
268+ url : './properties/Sublease/' + this . state . sublease . id ,
269+ data : {
270+ varname : 'hideContact' ,
271+ value : false
272+ } ,
273+ dataType : 'json' ,
274+ type : 'patch' ,
275+ success : function ( ) {
276+ this . setValue ( 'hideContact' , false )
277+ } . bind ( this )
278+ } )
279+ }
280+
247281 updateRent ( e ) {
248282 const rent = e . target . value . replace ( / [ ^ \d ] / g, '' )
249283 this . setError ( 'monthly_rent' , empty ( rent ) )
@@ -288,40 +322,35 @@ export default class SubleaseForm extends Base {
288322 onClose = { this . unsetMessage } />
289323 }
290324
325+ let hideContactButton
326+ if ( empty ( sublease . hideContact ) ) {
327+ hideContactButton = (
328+ < div key = "1" onClick = { this . hideContact } className = "lead pointer text-success" > < FontAwesomeIcon icon = { faToggleOn } /> Contact information shown to everyone</ div >
329+ )
330+ } else {
331+ hideContactButton = (
332+ < div key = "2" onClick = { this . showContact } className = "lead pointer text-danger" > < FontAwesomeIcon icon = { faToggleOff } /> Contact information shown only to other students.</ div >
333+ )
334+ }
335+
291336 let activateButton
292- let deactivateButton
293- let showActivate = 'd-inline'
294- let showDeactivate = 'd-inline'
295337 if ( sublease . id > 0 ) {
296338 if ( empty ( sublease . active ) ) {
297- showDeactivate = 'd-none'
339+ activateButton = (
340+ < div key = "3" onClick = { this . activate } className = "lead pointer text-danger" > < FontAwesomeIcon icon = { faToggleOff } /> Sublease inactive</ div >
341+ )
298342 } else {
299- showActivate = 'd-none'
343+ activateButton = (
344+ < div key = "4" onClick = { this . deactivate } className = "lead pointer text-success" > < FontAwesomeIcon icon = { faToggleOn } /> Sublease active</ div >
345+ )
300346 }
301-
302- activateButton = (
303- < div
304- key = "1"
305- onClick = { this . activate }
306- className = { `lead pointer text-muted ${ showActivate } ` } >
307- < i className = "fa fa-toggle-off" > </ i > Sublease inactive</ div >
308- )
309-
310- deactivateButton = (
311- < div
312- key = "2"
313- onClick = { this . deactivate }
314- className = { `lead pointer text-success ${ showDeactivate } ` } >
315- < i className = "fa fa-toggle-on" > </ i > Sublease active</ div >
316- )
317347 }
318348
319349 let contactAlert
320350 if ( this . state . sublease . id === 0 ) {
321351 contactAlert = (
322352 < div className = "alert alert-info" >
323- < strong > Notice:</ strong > a sublease listing requires contact information.< br />
324- Use our < a href = "./properties/Roommate" > roommate section</ a > ifyouwanttokeep your contact information available only to other students.</ div >
353+ < strong > Notice:</ strong > a sublease listing requires contact information.</ div >
325354 )
326355 }
327356
@@ -355,8 +384,8 @@ export default class SubleaseForm extends Base {
355384 < h2 > { suffixTitle } my sublease</ h2 >
356385 { message }
357386 { contactAlert }
358- < div className = "text-align mb-1" >
359- { activateButton } { deactivateButton }
387+ < div className = "mb-1" >
388+ { activateButton }
360389 </ div >
361390 < div className = "row" >
362391 < div className = "col-sm-6" >
@@ -397,6 +426,7 @@ export default class SubleaseForm extends Base {
397426 onChange = { this . setValue . bind ( this , 'description' ) } />
398427 </ div >
399428 </ div >
429+ { hideContactButton }
400430 < div className = "row" >
401431 < div className = "col-sm-6" >
402432 < InputField
0 commit comments