const CreateOppHeader = sources => {
  const oppForm = OppForm(sources)

  const submit$ = _submitAction$(sources)

  const queue$ = oppForm.item$
    .sample(submit$)
    .zip(sources.projectKey$,
      (opp,projectKey) => ({projectKey, ...opp})
    )
    .map(Opps.create)

  const isOpen$ = _openActions$(sources)
    .merge(submit$.map(false))
    .startWith(false)

  const viewState = {
    isOpen$,
    project$: sources.project$,
    oppFormDOM$: oppForm.DOM,
  }

  const DOM = combineLatestObj(viewState).map(_render)

  return {DOM, queue$}
}
const CreateOppListItem = sources => {
  const form = OppForm(sources)

  const listItem = ListItemWithDialog({...sources,
    iconName$: just('power'),
    title$: just('Create an Opportunity to get volunteers.'),
    dialogTitleDOM$: just('Create an Opportunity'),
    dialogContentDOM$: form.DOM,
  })

  const queue$ = form.item$
    .sample(listItem.submit$)
    .zip(sources.projectKey$, (opp,projectKey) => ({projectKey, ...opp}))
    .map(Opps.create)

  return {
    DOM: listItem.DOM,
    queue$,
  }
}
Beispiel #3
0
const CreateOppHeader = sources => {
  const form = OppForm(sources)

  const item = ListItemWithDialog({...sources,
    title$: just('opportunities'),
    dialogTitleDOM$: just('Create Opportunity'),
    dialogContentDOM$: form.DOM,
    rightDOM$: just(icon('plus')),
    dialogIconName$: just('power'),
    classes$: just({header: true}),
  })

  const queue$ = form.item$
    .sample(item.submit$)
    .zip(sources.projectKey$,
      (opp,projectKey) => ({projectKey, ...opp})
    )
    .map(Opps.create)

  return {
    DOM: item.DOM,
    queue$,
  }
}