fc77ee76d6
The primary license of the project is changing to: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later The Additional Permission is designed to permit publicly distributed Javascript code to be relicensed under LGPL-3.0-or-later, but not server-side Javascript code. As such, we've relicensed here static Javscript files under LGPL-3.0-or-later, and those that run as part of build and/or server side under AGPL-3.0-or-later. Note that in future, Javascript files may be updated to be stronger copyleft license with the Additional Permission, particularly if they adapted to run on server side and/or turned into templates. Of course, we'd seek public discussion with the contributor community about such changes. This commit is one of the many steps to relicense the entire codebase. Documentation granting permission for this relicensing (from all past contributors who hold copyrights) is on file with Software Freedom Conservancy, Inc.
44 lines
1 KiB
JavaScript
44 lines
1 KiB
JavaScript
// License: LGPL-3.0-or-later
|
|
const R = require('ramda')
|
|
const h = require('snabbdom/h')
|
|
const uuid = require('uuid')
|
|
const flyd = require('flyd')
|
|
const modal = require('ff-core/modal')
|
|
const mergeAll = require('flyd/module/mergeall')
|
|
|
|
// show$ is the stream that shows the confirmation modal
|
|
const init = show$ => {
|
|
const state = {
|
|
confirm$: flyd.stream()
|
|
, unconfirm$: flyd.stream()
|
|
, ID: uuid.v1()
|
|
}
|
|
|
|
state.modalID$ = mergeAll([
|
|
flyd.map(R.always(state.ID), show$)
|
|
, flyd.map(R.always(null), state.unconfirm$)
|
|
, flyd.map(R.always(null), state.confirm$)])
|
|
|
|
return state
|
|
}
|
|
|
|
// msg is optional
|
|
const view = (state, msg) =>
|
|
modal({
|
|
id$: state.modalID$
|
|
, thisID: state.ID
|
|
, notCloseable: true
|
|
, body: h('div', [
|
|
h('h4', msg || 'Are you sure?')
|
|
, h('div', [
|
|
h('button', {attrs: {'data-ff-confirm': true}, on: {click: state.confirm$}}
|
|
, 'Yes')
|
|
, h('button', {attrs: {'data-ff-confirm': false}, on: {click: state.unconfirm$}}
|
|
, 'No')
|
|
])
|
|
])
|
|
})
|
|
|
|
|
|
module.exports = {init, view}
|
|
|