From 60b97c3e3ea860898fb67362eaaace540cbd7eaf Mon Sep 17 00:00:00 2001 From: Ben Hejkal Date: Thu, 19 Dec 2024 11:52:48 -0600 Subject: [PATCH 1/2] remove ramda from settings (incomplete) --- client/js/settings/index/branding/index.js | 5 ++--- client/js/settings/index/branding/view.js | 2 +- client/js/settings/index/email-settings/index.js | 8 ++++---- client/js/settings/index/integrations/index.js | 3 +-- client/js/settings/index/page.js | 1 - 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/client/js/settings/index/branding/index.js b/client/js/settings/index/branding/index.js index e4f62cc12..59f4f4d7e 100644 --- a/client/js/settings/index/branding/index.js +++ b/client/js/settings/index/branding/index.js @@ -1,7 +1,6 @@ // License: LGPL-3.0-or-later // npm const flyd = require('flyd') -const R = require('ramda') flyd.flatMap = require('flyd/module/flatmap') flyd.filter = require('flyd/module/filter') flyd.mergeAll = require('flyd/module/mergeall') @@ -13,7 +12,7 @@ const colorPicker = require('../../../components/color-picker.es6') const view = require('./view') function init() { - const np = R.merge(app.nonprofit, {}) + const np = { ...app.nonprofit } const state = { nonprofit: np , font$: flyd.stream({ @@ -27,7 +26,7 @@ function init() { } const resp$ = flyd.flatMap( - state => flyd.map(R.prop('body'), request({ + state => flyd.map(r => r.body, request({ method: 'put' , path: `/nonprofits/${np.id}` , send: {nonprofit: { brand_color: state.colorPicker.color$(), brand_font: state.font$().key }} diff --git a/client/js/settings/index/branding/view.js b/client/js/settings/index/branding/view.js index 68d7f5aa5..6aed91d25 100644 --- a/client/js/settings/index/branding/view.js +++ b/client/js/settings/index/branding/view.js @@ -46,7 +46,7 @@ const fontListing = state => const fontRow = R.curry((state, key, font) => h('li', { style: { fontFamily: font.family } - , on: {click: [state.font$, R.merge(font, {key: key})]} + , on: {click: [state.font$, {...font, key}]} }, font.name) ) diff --git a/client/js/settings/index/email-settings/index.js b/client/js/settings/index/email-settings/index.js index 6dcb4ca28..a8dc74ba8 100644 --- a/client/js/settings/index/email-settings/index.js +++ b/client/js/settings/index/email-settings/index.js @@ -18,7 +18,7 @@ function init() { // formSerialize will set checked boxes to "on" and unchecked boxes to "". We want it to be true/false instead const formObj$ = R.compose( - flyd.map(obj => R.map(val => val === 'on' ? true : false, obj)) + flyd.map(obj => obj.map(val => val === 'on' ? true : false)) , flyd.map(ev => serializeForm(ev.currentTarget, {hash: true, empty: true})) )(state.submit$) @@ -28,11 +28,11 @@ function init() { obj => request({ path, method: 'post' , send: {email_settings: obj} }).load , formObj$ ) - state.email_settings$ = flyd.map(R.prop('body'), request({method: 'get', path}).load) + state.email_settings$ = flyd.map((r) => r.body, request({ method: 'get', path }).load); state.loading$ = flyd.mergeAll([ - flyd.map(R.always(true), state.submit$) - , flyd.map(R.always(false), updateResp$) + flyd.map(() => true, state.submit$) + , flyd.map(() => false, updateResp$) ]) const notify$ = flyd.map(()=> 'Email notification settings updated.', updateResp$) diff --git a/client/js/settings/index/integrations/index.js b/client/js/settings/index/integrations/index.js index a39e36417..6dd55bbb0 100644 --- a/client/js/settings/index/integrations/index.js +++ b/client/js/settings/index/integrations/index.js @@ -1,6 +1,5 @@ // License: LGPL-3.0-or-later const h = require('snabbdom/h') -const R = require('ramda') const flyd = require('flyd') const request = require('../../../common/request') const colors = require('../../../common/colors') @@ -10,7 +9,7 @@ function init() { clickSync$: flyd.stream() , mailchimpKeyResp$: request({method: 'get', path: `/nonprofits/${app.nonprofit_id}/nonprofit_keys`, query: {select: 'mailchimp_token'}}).load } - state.mailchimpKey$ = flyd.map(R.prop('response'), flyd.filter(resp => resp.status === 200, state.mailchimpKeyResp$)) + state.mailchimpKey$ = flyd.map(r => r.response, flyd.filter(resp => resp.status === 200, state.mailchimpKeyResp$)) return state } diff --git a/client/js/settings/index/page.js b/client/js/settings/index/page.js index 80d642970..ece86fbcd 100644 --- a/client/js/settings/index/page.js +++ b/client/js/settings/index/page.js @@ -6,7 +6,6 @@ require('../../common/restful_resource') const render = require('ff-core/render') const h = require('snabbdom/h') -const R = require('ramda') const flyd = require('flyd') const snabbdom = require('snabbdom') const branding = require('./branding/index') From c395ad66a49fdbb3fec294f5113c1a3e5705641e Mon Sep 17 00:00:00 2001 From: Ben Hejkal Date: Fri, 20 Dec 2024 11:31:59 -0600 Subject: [PATCH 2/2] remove remaining ramda from settings --- client/js/settings/index/branding/view.js | 8 ++++---- client/js/settings/index/email-settings/index.js | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/client/js/settings/index/branding/view.js b/client/js/settings/index/branding/view.js index 6aed91d25..e0ebb3f15 100644 --- a/client/js/settings/index/branding/view.js +++ b/client/js/settings/index/branding/view.js @@ -1,7 +1,6 @@ // License: LGPL-3.0-or-later // npm const h = require('snabbdom/h') -const R = require('ramda') const notification = require('ff-core/notification') const button = require('ff-core/button') // local @@ -41,14 +40,15 @@ const fontPicker = state => ]) const fontListing = state => - h('ul.inner', R.map(R.apply(fontRow(state)), R.toPairs(fonts))) + h('ul.inner', Object.entries(fonts).map( + ([key, value]) => fontRow(state, key, value) + )) -const fontRow = R.curry((state, key, font) => +const fontRow = (state, key, font) => h('li', { style: { fontFamily: font.family } , on: {click: [state.font$, {...font, key}]} }, font.name) -) const form = state => { var btn = button({ buttonText: 'Save Branding' , loading$: state.loading$ }) diff --git a/client/js/settings/index/email-settings/index.js b/client/js/settings/index/email-settings/index.js index a8dc74ba8..033e21905 100644 --- a/client/js/settings/index/email-settings/index.js +++ b/client/js/settings/index/email-settings/index.js @@ -2,7 +2,6 @@ // npm const snabbdom = require('snabbdom') const flyd = require('flyd') -const R = require('ramda') const render = require('ff-core/render') const notification = require('ff-core/notification') const serializeForm = require('form-serialize') @@ -16,11 +15,8 @@ const view = require('./view') function init() { var state = { submit$: flyd.stream() } - // formSerialize will set checked boxes to "on" and unchecked boxes to "". We want it to be true/false instead - const formObj$ = R.compose( - flyd.map(obj => obj.map(val => val === 'on' ? true : false)) - , flyd.map(ev => serializeForm(ev.currentTarget, {hash: true, empty: true})) - )(state.submit$) + const intermediate = flyd.map(ev => serializeForm(ev.currentTarget, {hash: true, empty: true}, state.submit$)); + const formObj$ = flyd.map(obj => obj.map(val => val === 'on' ? true : false), intermediate); const path = `/nonprofits/${app.nonprofit_id}/users/${app.current_user_id}/email_settings`