Skip to content

Instantly share code, notes, and snippets.

@kingsleyh
Created July 17, 2017 21:05
Show Gist options
  • Save kingsleyh/0994e0d4e0d40078210184e94d26ffd3 to your computer and use it in GitHub Desktop.
Save kingsleyh/0994e0d4e0d40078210184e94d26ffd3 to your computer and use it in GitHub Desktop.
Halogen wrapping
"use strict";
exports.alert_ = function(callback) {
return function(config) {
return function() {
var title = config.title;
var text = config.text;
var confirmButton = config.confirmButton;
var cancelButton = config.cancelButton;
var showCancelButton = config.showCancelButton;
return sweetAlert({
reverseButtons: true,
title: title,
html: text,
showCancelButton: showCancelButton,
confirmButtonText: confirmButton,
cancelButtonText: cancelButton,
buttonsStyling: false,
confirmButtonClass: 'button-master button-primary',
cancelButtonClass: 'button-master button-cancel',
allowOutsideClick: false
}).then(function() {
callback(true)();
}).catch(function() {
callback(false)();
});
};
}
};
module UserManagement.SweetAlert (Config, alert) where
import UserManagement.Models
import Control.Monad.Eff.Exception (EXCEPTION, throw)
import Control.Monad.Eff.Console (log, CONSOLE)
import Control.Monad.Aff (Aff, makeAff)
import Network.HTTP.Affjax (AJAX, get, put)
import Prelude (Unit)
import Control.Monad.Eff
type Config = {
title :: String
, text :: String
, confirmButton :: String
, cancelButton :: String
, showCancelButton :: Boolean
}
foreign import alert_ :: forall e. (Boolean -> Eff e Unit) -> Config -> Eff e Unit
alert :: forall e. Config -> Aff e Boolean
alert config = makeAff (\error success -> alert_ success config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment