[Common UI] Initial commonUI bundles

Bring in work on general-purpose and over-arching
user interface bundles from the sandbox transition
branch. WTD-574.
This commit is contained in:
Victor Woeltjen
2014-11-23 15:41:20 -08:00
parent 0cd331e8a5
commit 1b0303e517
73 changed files with 6035 additions and 0 deletions

View File

@ -0,0 +1,79 @@
/*global define,Promise*/
/**
* Module defining DialogService. Created by vwoeltje on 11/10/14.
*/
define(
[],
function () {
"use strict";
/**
*
* @constructor
*/
function DialogService($document, $compile, $rootScope, $timeout, $q, $log) {
var scope;
function addContent() {
scope = $rootScope.$new();
$document.find('body').prepend(
$compile(
"<mct-include ng-model=\"dialog\" key=\"'overlay-dialog'\"></mct-include>"
)(scope)
);
scope.dialog = { visible: false, value: {} };
}
function dismiss() {
scope.dialog = { visible: false, value: {} };
}
return {
getUserInput: function (formModel, value) {
var deferred = $q.defer();
if (!scope) {
addContent();
}
$timeout(function () {
if (scope.dialog.visible) {
$log.warn([
"Dialog already showing; ",
"unable to show ",
title
].join(""));
}
scope.dialog.visible = true;
scope.dialog.title = formModel.name;
scope.dialog.message = formModel.message;
scope.dialog.formModel = formModel;
scope.dialog.value = JSON.stringify(value);
scope.dialog.confirm = function () {
var resultingValue;
try {
resultingValue = JSON.parse(scope.dialog.value);
} catch (e) {
resultingValue = {};
}
deferred.resolve(resultingValue);
dismiss();
};
scope.dialog.cancel = function () {
deferred.reject();
dismiss();
};
});
return deferred.promise;
}
};
}
return DialogService;
}
);