Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1608 | Rev 1610 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1608 Rev 1609
Línea 57... Línea 57...
57
      description: '',
57
      description: '',
58
      share_width: 'p'
58
      share_width: 'p'
59
    }
59
    }
60
  })
60
  })
Línea 61... Línea -...
61
 
-
 
62
  useEffect(() => {
-
 
63
    register('description', {
-
 
64
      required: { value: 'true', message: 'El campo es requerido' }
-
 
65
    })
-
 
66
 
-
 
67
    register('posted_or_shared')
-
 
68
    if (
-
 
69
      modalType !== shareModalTypes.POST &&
-
 
70
      modalType !== shareModalTypes.SHARE
-
 
71
    ) {
-
 
72
      register('file', {
-
 
73
        required: { value: 'true', message: 'El campo es requerido' }
-
 
74
      })
-
 
75
    } else {
-
 
76
      if (!getValues('file')) unregister('file')
-
 
77
    }
-
 
78
  }, [modalType])
-
 
79
 
61
 
80
  const recomendationText = () => {
62
  const recomendationText = () => {
81
    switch (modalType) {
63
    switch (modalType) {
82
      case shareModalTypes.IMAGE:
64
      case shareModalTypes.IMAGE:
83
        return 'Tamaño recomendado: 720x720'
65
        return 'Tamaño recomendado: 720x720'
Línea 87... Línea 69...
87
        return 'Video de extensión mp4, mpeg, webm, mov'
69
        return 'Video de extensión mp4, mpeg, webm, mov'
88
      default:
70
      default:
89
        return ''
71
        return ''
90
    }
72
    }
91
  }
73
  }
92
  useEffect(() => {
-
 
93
    const postedOrShared = modalType === shareModalTypes.SHARE ? 's' : 'p'
-
 
94
    setValue('posted_or_shared', postedOrShared)
-
 
95
    if (getValues('file') || getValues('description')) {
-
 
96
      if (modalType !== lastModalType) {
-
 
97
        closeShareModal()
-
 
98
        toggleConfirmModal()
-
 
99
      }
-
 
100
    }
-
 
101
  }, [modalType])
-
 
102
 
-
 
103
  const hideDuplicatedModal = () => {
-
 
104
    setTimeout(() => {
-
 
105
      const modals = document.getElementsByClassName('modal')
-
 
106
      if (modals.length > 1 && modals[0].style.display !== 'none') {
-
 
107
        const currentModal = modals[0]
-
 
108
        currentModal.style.display = 'none'
-
 
109
        for (let index = 0; index < modals.length; index++) {
-
 
110
          const element = modals[index]
-
 
111
          element.removeAttribute('tabindex')
-
 
112
        }
-
 
113
      }
-
 
114
    }, 3000)
-
 
115
  }
-
 
116
 
-
 
117
  useEffect(() => {
-
 
118
    clearErrors()
-
 
119
    hideDuplicatedModal()
-
 
120
  }, [isOpen])
-
 
Línea 121... Línea 74...
121
 
74
 
Línea 122... Línea 75...
122
  const toggleConfirmModal = () => setShowConfirmModal(!showConfirmModal)
75
  const toggleConfirmModal = () => setShowConfirmModal(!showConfirmModal)
123
 
76
 
Línea 134... Línea 87...
134
    closeShareModal()
87
    closeShareModal()
135
    setModalType(lastModalType)
88
    setModalType(lastModalType)
136
    openShareModal(postUrl, lastModalType, feedType)
89
    openShareModal(postUrl, lastModalType, feedType)
137
  }
90
  }
Línea 138... Línea 91...
138
 
91
 
139
  const onSubmit = (data) => {
92
  const onSubmit = handleSubmit((data) => {
140
    setLoading(true)
93
    setLoading(true)
Línea 141... Línea 94...
141
    const currentFormData = new FormData()
94
    const currentFormData = new FormData()
142
 
95
 
Línea 179... Línea 132...
179
        if (currentPage && timelineUrl) {
132
        if (currentPage && timelineUrl) {
180
          fetchFeeds(timelineUrl, currentPage)
133
          fetchFeeds(timelineUrl, currentPage)
181
        }
134
        }
182
      })
135
      })
183
      .finally(() => setLoading(false))
136
      .finally(() => setLoading(false))
184
  }
137
  })
Línea 185... Línea 138...
185
 
138
 
186
  const onUploadedHandler = (files) => {
139
  const onUploadedHandler = (files) => {
187
    setValue('file', files)
140
    setValue('file', files)
188
    clearErrors('file')
141
    clearErrors('file')
Línea 189... Línea 142...
189
  }
142
  }
-
 
143
 
-
 
144
  const onClose = () => {
-
 
145
    clearErrors()
-
 
146
    closeShareModal()
-
 
147
  }
-
 
148
 
-
 
149
  useEffect(() => {
-
 
150
    const postedOrShared = modalType === shareModalTypes.SHARE ? 's' : 'p'
-
 
151
 
-
 
152
    register('posted_or_shared')
190
 
153
    setValue('posted_or_shared', postedOrShared)
191
  const dropZoneRender = () => {
154
 
192
    if (
155
    if (
193
      modalType !== shareModalTypes.POST &&
156
      modalType !== shareModalTypes.POST &&
194
      modalType !== shareModalTypes.SHARE
157
      modalType !== shareModalTypes.SHARE
195
    ) {
-
 
196
      return (
-
 
197
        <DropzoneComponent
-
 
198
          modalType={modalType}
158
    ) {
199
          onUploaded={onUploadedHandler}
-
 
200
          settedFile={getValues('file')}
159
      register('file', {
201
          recomendationText={recomendationText()}
160
        required: { value: 'true', message: 'El campo es requerido' }
-
 
161
      })
202
        />
162
    } else {
203
      )
-
 
Línea 204... Línea 163...
204
    }
163
      if (!getValues('file')) unregister('file')
205
  }
164
    }
206
 
-
 
207
  const SharedWithSelectRender = () => {
-
 
208
    if (feedType === feedTypes.DASHBOARD) {
165
 
209
      return (
-
 
210
        <>
-
 
211
          <select
-
 
212
            name='shared_with'
-
 
213
            className='form-control'
-
 
214
            ref={register({ required: 'El campo es requerido' })}
-
 
215
          >
166
    if (getValues('file') || getValues('description')) {
216
            <option disabled='disabled' value='' style={{ display: 'none' }}>
-
 
217
              {labels.share_with}
-
 
218
            </option>
-
 
219
            <option value='p'>{labels.public}</option>
-
 
220
            <option value='c'>{labels.connections}</option>
-
 
221
          </select>
-
 
222
          {errors.shared_with && (
-
 
223
            <FormErrorFeedback>{errors.shared_with.message}</FormErrorFeedback>
167
      if (modalType !== lastModalType) {
224
          )}
168
        onClose()
-
 
169
        toggleConfirmModal()
-
 
170
      }
-
 
171
    }
-
 
172
  }, [modalType])
-
 
173
 
225
        </>
174
  useEffect(() => {
-
 
175
    register('description', {
Línea 226... Línea 176...
226
      )
176
      required: { value: 'true', message: 'El campo es requerido' }
227
    }
177
    })
228
  }
178
  }, [])
229
 
179
 
230
  return (
180
  return (
231
    <>
181
    <>
232
      <Modal
182
      <Modal
233
        show={isOpen}
183
        show={isOpen}
234
        title={labels.share_a_post}
184
        title={labels.share_a_post}
235
        labelAccept={labels.send}
185
        labelAccept={labels.send}
-
 
186
        labelReject={labels.cancel}
-
 
187
        onClose={onClose}
-
 
188
        onAccept={onSubmit}
-
 
189
      >
236
        labelReject={labels.cancel}
190
        {feedType === feedTypes.DASHBOARD ? (
-
 
191
          <select name='shared_with' className='form-control' defaultValue='p'>
Línea 237... Línea 192...
237
        onClose={closeShareModal}
192
            <option value='p'>{labels.public}</option>
238
        onAccept={handleSubmit(onSubmit)}
193
            <option value='c'>{labels.connections}</option>
239
      >
194
          </select>
240
        {SharedWithSelectRender()}
195
        ) : null}
Línea 254... Línea 209...
254
 
209
 
255
        {errors.description && (
210
        {errors.description && (
256
          <FormErrorFeedback>{errors.description.message}</FormErrorFeedback>
211
          <FormErrorFeedback>{errors.description.message}</FormErrorFeedback>
Línea -... Línea 212...
-
 
212
        )}
257
        )}
213
 
-
 
214
        {![shareModalTypes.POST, shareModalTypes.SHARE].includes(modalType) ? (
-
 
215
          <DropzoneComponent
-
 
216
            modalType={modalType}
-
 
217
            onUploaded={onUploadedHandler}
-
 
218
            settedFile={getValues('file')}
-
 
219
            recomendationText={recomendationText()}
Línea 258... Línea 220...
258
 
220
          />
259
        {dropZoneRender()}
221
        ) : null}
260
 
222