From caf2a025ce80352b9162abba4f8789f683359d73 Mon Sep 17 00:00:00 2001 From: Robrecht Siera Date: Wed, 29 May 2019 17:16:08 +0200 Subject: [PATCH 01/17] sync dll version with .dnn version --- OpenContent/Properties/AssemblyInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenContent/Properties/AssemblyInfo.cs b/OpenContent/Properties/AssemblyInfo.cs index ad2bcae1..773d0c03 100644 --- a/OpenContent/Properties/AssemblyInfo.cs +++ b/OpenContent/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Satrabel")] [assembly: AssemblyProduct("OpenContent")] -[assembly: AssemblyCopyright("Copyright © 2015-2017")] +[assembly: AssemblyCopyright("Copyright © 2015-2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -30,5 +30,5 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("04.00.00.0")] -[assembly: AssemblyFileVersion("04.00.00.0")] +[assembly: AssemblyVersion("04.02.00.0")] +[assembly: AssemblyFileVersion("04.02.00.0")] From 0762ae8438ccceaf5f945d00ef62170efbc257f7 Mon Sep 17 00:00:00 2001 From: Sacha Trauwaen Date: Tue, 11 Jun 2019 11:57:26 +0200 Subject: [PATCH 02/17] armonize image2 and image2ml + only show first template of folder in list init screen --- OpenContent/Components/Files/PortalFileUri.cs | 12 ++++++++---- OpenContent/Components/Form/FormUtils.cs | 2 +- OpenContent/Components/InitAPIController.cs | 6 +++--- .../Components/Render/ModelFactoryBase.cs | 15 +++++++++++++++ .../Components/Render/ModelFactoryMultiple.cs | 17 ++--------------- .../Components/Render/ModelFactorySingle.cs | 1 + .../Components/Utils/OpenContentUtils.cs | 15 ++++++++++----- OpenContent/View.ascx | 16 ++++++++++------ 8 files changed, 50 insertions(+), 34 deletions(-) diff --git a/OpenContent/Components/Files/PortalFileUri.cs b/OpenContent/Components/Files/PortalFileUri.cs index b4e4017c..1612cba8 100644 --- a/OpenContent/Components/Files/PortalFileUri.cs +++ b/OpenContent/Components/Files/PortalFileUri.cs @@ -172,10 +172,14 @@ public string EditUrl() //var url = Globals.NavigateURL(tabFileManager); //var dnnFileManagerModule = DnnUtils.GetDnnModulesByFriendlyName("filemanager", tabFileManager).OrderByDescending(m=> m.ModuleID).FirstOrDefault(); var dnnFileManagerModule = DnnUtils.GetLastModuleByFriendlyName("Digital Asset Management"); - var modId = dnnFileManagerModule.ModuleID; - //var modId = 1420; - var url = Globals.NavigateURL(dnnFileManagerModule.TabID, "FileProperties", "mid=" + modId, "popUp=true", "fileId=" + FileInfo.FileId); - return $"javascript:dnnModal.show('{url}',/*showReturn*/false,550,950,true,'')"; + if (dnnFileManagerModule != null) + { + var modId = dnnFileManagerModule.ModuleID; + //var modId = 1420; + var url = Globals.NavigateURL(dnnFileManagerModule.TabID, "FileProperties", "mid=" + modId, "popUp=true", "fileId=" + FileInfo.FileId); + return $"javascript:dnnModal.show('{url}',/*showReturn*/false,550,950,true,'')"; + } + return ""; //javascript:dnnModal.show('http://localhost:54068/en-us/OpenFiles/ctl/Module/ModuleId/487/view/gridview/pageSize/10?ReturnURL=/en-us/OpenFiles?folderId=42&popUp=true',/*showReturn*/false,550,950,true,'') //return string.Format("javascript:dnnModal.show('{0}/ctl/FileProperties/mid/{2}?popUp=true&fileId={1}')", url, FileInfo.FileId, modId); } diff --git a/OpenContent/Components/Form/FormUtils.cs b/OpenContent/Components/Form/FormUtils.cs index 9497f818..0ed58390 100644 --- a/OpenContent/Components/Form/FormUtils.cs +++ b/OpenContent/Components/Form/FormUtils.cs @@ -101,7 +101,7 @@ private static bool IsValidEmail(string strIn) { strIn = Regex.Replace(strIn, @"(@)(.+)$", DomainMapper); } - catch (Exception e) + catch (Exception) { invalid = true; } diff --git a/OpenContent/Components/InitAPIController.cs b/OpenContent/Components/InitAPIController.cs index ec65847e..321e1fe0 100644 --- a/OpenContent/Components/InitAPIController.cs +++ b/OpenContent/Components/InitAPIController.cs @@ -72,10 +72,10 @@ public List GetModules() [ValidateAntiForgeryToken] [DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Admin)] [HttpGet] - public List GetTemplates() + public List GetTemplates(bool advanced) { var scriptFileSetting = ActiveModule.OpenContentSettings().Template; - var templates = OpenContentUtils.ListOfTemplatesFiles(PortalSettings, ActiveModule.ModuleID, scriptFileSetting, App.Config.Opencontent); + var templates = OpenContentUtils.ListOfTemplatesFiles(PortalSettings, ActiveModule.ModuleID, scriptFileSetting, App.Config.Opencontent, !advanced); return templates.Select(t => new TemplateDto() { Value = t.Value, @@ -100,7 +100,7 @@ public List GetTemplates(int tabModuleId) [ValidateAntiForgeryToken] [DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Admin)] [HttpGet] - public List GetTemplates(bool web) + public List GetNewTemplates(bool web) { if (web) { diff --git a/OpenContent/Components/Render/ModelFactoryBase.cs b/OpenContent/Components/Render/ModelFactoryBase.cs index 2800ba0c..4f8dc3ea 100644 --- a/OpenContent/Components/Render/ModelFactoryBase.cs +++ b/OpenContent/Components/Render/ModelFactoryBase.cs @@ -120,6 +120,21 @@ public Dictionary GetModelAsDictionary(bool onlyData = false, bo public abstract JToken GetModelAsJson(bool onlyData = false, bool onlyMainData = false); + protected void EnhanceImages(JObject model) + { + if (_optionsJson == null) + { + var alpaca = _ds.GetAlpaca(_dsContext, true, true, false); + + if (alpaca != null) + { + _schemaJson = alpaca["schema"] as JObject; // cache + _optionsJson = alpaca["options"] as JObject; // cache + } + } + JsonUtils.ImagesJson(model, Options, _optionsJson, IsEditMode); + } + protected void EnhanceSelect2(JObject model, bool onlyData) { string colName = string.IsNullOrEmpty(_collection) ? "Items" : _collection; diff --git a/OpenContent/Components/Render/ModelFactoryMultiple.cs b/OpenContent/Components/Render/ModelFactoryMultiple.cs index 61fd7598..1e672a45 100644 --- a/OpenContent/Components/Render/ModelFactoryMultiple.cs +++ b/OpenContent/Components/Render/ModelFactoryMultiple.cs @@ -96,7 +96,7 @@ public override JToken GetModelAsJson(bool onlyData = false, bool onlyMainData = JsonUtils.SimplifyJson(dyn, GetCurrentCultureCode()); EnhanceSelect2(dyn, onlyData); EnhanceUser(dyn, item.CreatedByUserId); - EnhanceImages(dyn, itemsModel); + EnhanceImages(dyn); if (onlyData) { RemoveNoData(itemsModel); @@ -164,20 +164,7 @@ private void EnhanceUser(JObject model, int createdByUserId) } } } - private void EnhanceImages(JObject model, JObject itemsModel) - { - if (_optionsJson == null) - { - var alpaca = _ds.GetAlpaca(_dsContext, true, true, false); - - if (alpaca != null) - { - _schemaJson = alpaca["schema"] as JObject; // cache - _optionsJson = alpaca["options"] as JObject; // cache - } - } - JsonUtils.ImagesJson(model, Options, _optionsJson, IsEditMode); - } + private static void RemoveNoData(JObject model) { diff --git a/OpenContent/Components/Render/ModelFactorySingle.cs b/OpenContent/Components/Render/ModelFactorySingle.cs index 4d859024..d342ca4a 100644 --- a/OpenContent/Components/Render/ModelFactorySingle.cs +++ b/OpenContent/Components/Render/ModelFactorySingle.cs @@ -42,6 +42,7 @@ public override JToken GetModelAsJson(bool onlyData = false, bool onlyMainData = ExtendModel(enhancedModel, onlyData, onlyMainData); ExtendModelSingle(enhancedModel); EnhanceSelect2(model, onlyData); + EnhanceImages(model); JsonUtils.Merge(model, enhancedModel); JsonUtils.SimplifyJson(model, GetCurrentCultureCode()); return model; diff --git a/OpenContent/Components/Utils/OpenContentUtils.cs b/OpenContent/Components/Utils/OpenContentUtils.cs index 2faf7ffc..f055b5f6 100644 --- a/OpenContent/Components/Utils/OpenContentUtils.cs +++ b/OpenContent/Components/Utils/OpenContentUtils.cs @@ -98,12 +98,12 @@ public static List GetTemplates(PortalSettings portalSettings, int mod /// The selected template. /// The module sub dir. /// - public static List ListOfTemplatesFiles(PortalSettings portalSettings, int moduleId, TemplateManifest selectedTemplate, string moduleSubDir) + public static List ListOfTemplatesFiles(PortalSettings portalSettings, int moduleId, TemplateManifest selectedTemplate, string moduleSubDir, bool onePerFolder = false) { - return ListOfTemplatesFiles(portalSettings, moduleId, selectedTemplate, moduleSubDir, null); + return ListOfTemplatesFiles(portalSettings, moduleId, selectedTemplate, moduleSubDir, null, onePerFolder); } - public static List ListOfTemplatesFiles(PortalSettings portalSettings, int moduleId, TemplateManifest selectedTemplate, string moduleSubDir, FileUri otherModuleTemplate) + public static List ListOfTemplatesFiles(PortalSettings portalSettings, int moduleId, TemplateManifest selectedTemplate, string moduleSubDir, FileUri otherModuleTemplate, bool onePerFolder = false) { string basePath = HostingEnvironment.MapPath(GetSiteTemplateFolder(portalSettings, moduleSubDir)); if (!Directory.Exists(basePath)) @@ -162,7 +162,9 @@ public static List ListOfTemplatesFiles(PortalSettings portalSettings, string templateName = Path.GetDirectoryName(manifestFile).Substring(basePath.Length).Replace("\\", " / "); if (!String.IsNullOrEmpty(template.Value.Title)) { - templateName = templateName + " - " + template.Value.Title; + if (!onePerFolder) + templateName = templateName + " - " + template.Value.Title; + } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + templateName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) @@ -170,6 +172,7 @@ public static List ListOfTemplatesFiles(PortalSettings portalSettings, item.Selected = true; } lst.Add(item); + if (onePerFolder) break; } } } @@ -246,7 +249,8 @@ public static List ListOfTemplatesFiles(PortalSettings portalSettings, string templateName = Path.GetDirectoryName(manifestFile).Substring(basePath.Length).Replace("\\", " / "); if (!String.IsNullOrEmpty(template.Value.Title)) { - templateName = templateName + " - " + template.Value.Title; + if (!onePerFolder) + templateName = templateName + " - " + template.Value.Title; } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + templateName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) @@ -254,6 +258,7 @@ public static List ListOfTemplatesFiles(PortalSettings portalSettings, item.Selected = true; } lst.Add(item); + if (onePerFolder) break; } } } diff --git a/OpenContent/View.ascx b/OpenContent/View.ascx index 1d8f3686..b1fdf9ca 100644 --- a/OpenContent/View.ascx +++ b/OpenContent/View.ascx @@ -50,7 +50,7 @@ {{val.Text}}
@@ -249,7 +249,7 @@ self.dataNeeded = data.DataNeeded; self.dataDefined = data.DataDefined; }); - this.apiGet('GetTemplates', {}, function (data) { + this.apiGet('GetTemplates', {advanced: this.advanced}, function (data) { self.templates = data; self.loading = false; if (self.templates.length == 0) { @@ -291,12 +291,16 @@ this.advanced = false; this.existingTemplateChange(); }, + goAdvanced: function () { + this.advanced = true; + this.existingTemplateChange(); + }, thisModuleChange: function () { this.UseTemplate = "0"; this.tabModuleId = 0; this.Template = ''; var self = this; - this.apiGet('GetTemplates', {}, function (data) { + this.apiGet('GetTemplates', {advanced: this.advanced}, function (data) { self.templates = data; }); }, @@ -327,14 +331,14 @@ fromWebChange: function () { var self = this; this.Template = ''; - this.apiGet('GetTemplates', { web: true }, function (data) { + this.apiGet('GetNewTemplates', { web: true }, function (data) { self.templates = data; }); }, fromSiteChange: function () { var self = this; this.Template = ''; - this.apiGet('GetTemplates', { web: false }, function (data) { + this.apiGet('GetNewTemplates', { web: false }, function (data) { self.templates = data; }); }, @@ -409,7 +413,7 @@ self.dataDefined = data.DataDefined; self.Template = data.Template; if (self.newTemplate) { - self.apiGet('GetTemplates', {}, function (dataTemplates) { + self.apiGet('GetTemplates', {advanced: this.advanced}, function (dataTemplates) { self.templates = dataTemplates; self.Template = data.Template; }); From d51ae3efabddd99a889055d1ef428aaa3ae1f368 Mon Sep 17 00:00:00 2001 From: Sacha Trauwaen Date: Wed, 12 Jun 2019 12:15:42 +0200 Subject: [PATCH 03/17] rmonize image2 and image2ml in lists --- OpenContent/Components/Json/JsonUtils.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenContent/Components/Json/JsonUtils.cs b/OpenContent/Components/Json/JsonUtils.cs index b9dfa06e..358529cc 100644 --- a/OpenContent/Components/Json/JsonUtils.cs +++ b/OpenContent/Components/Json/JsonUtils.cs @@ -421,7 +421,7 @@ public static void ImagesJson(JObject o, JObject requestOptions, JObject options var obj = value as JObject; if (obj != null) { - //LookupJson(obj, reqOpt, opt["items"] as JObject); + ImagesJson(obj, reqOpt, opt["items"] as JObject, isEditable); } else if (image) { @@ -432,7 +432,7 @@ public static void ImagesJson(JObject o, JObject requestOptions, JObject options { newArray.Add(GenerateImage(reqOpt, val.ToString(), isEditable)); } - catch (System.Exception) + catch (Exception) { } } @@ -446,7 +446,7 @@ public static void ImagesJson(JObject o, JObject requestOptions, JObject options else if (childProperty.Value is JObject) { var obj = childProperty.Value as JObject; - + ImagesJson(obj, reqOpt, opt, isEditable); } else if (childProperty.Value is JValue) { @@ -457,7 +457,7 @@ public static void ImagesJson(JObject o, JObject requestOptions, JObject options { o[childProperty.Name] = GenerateImage(reqOpt, val, isEditable); } - catch (System.Exception) + catch (Exception) { } } From 4e3a8057c18f29d84f99d830f3a6595d0c90e735 Mon Sep 17 00:00:00 2001 From: Sacha Trauwaen Date: Thu, 13 Jun 2019 10:23:21 +0200 Subject: [PATCH 04/17] fix NullReferenceExceptions with image2 and image2ml --- OpenContent/Components/Json/JsonUtils.cs | 11 +++++++---- OpenContent/TemplateInit.ascx.cs | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/OpenContent/Components/Json/JsonUtils.cs b/OpenContent/Components/Json/JsonUtils.cs index 358529cc..40e3df64 100644 --- a/OpenContent/Components/Json/JsonUtils.cs +++ b/OpenContent/Components/Json/JsonUtils.cs @@ -387,7 +387,7 @@ public static void LookupJson(JObject o, JObject additionalData, JObject schema, } } } - + /// /// Enhance data for all alpaca fields of type 'image2' and 'mlimage2' /// @@ -419,7 +419,7 @@ public static void ImagesJson(JObject o, JObject requestOptions, JObject options foreach (var value in array) { var obj = value as JObject; - if (obj != null) + if (obj != null && opt != null && opt["items"] != null) { ImagesJson(obj, reqOpt, opt["items"] as JObject, isEditable); } @@ -446,7 +446,10 @@ public static void ImagesJson(JObject o, JObject requestOptions, JObject options else if (childProperty.Value is JObject) { var obj = childProperty.Value as JObject; - ImagesJson(obj, reqOpt, opt, isEditable); + if (obj != null && opt != null) + { + ImagesJson(obj, reqOpt, opt, isEditable); + } } else if (childProperty.Value is JValue) { @@ -492,7 +495,7 @@ private static string GetFileEditUrl(IFileInfo f) return portalFileUri.EditUrl(); } - + private static JObject GenerateObject(JObject additionalData, string key, string id, string dataMember, string valueField, string childerenField) { diff --git a/OpenContent/TemplateInit.ascx.cs b/OpenContent/TemplateInit.ascx.cs index d5756c12..24b2357c 100644 --- a/OpenContent/TemplateInit.ascx.cs +++ b/OpenContent/TemplateInit.ascx.cs @@ -35,7 +35,7 @@ protected void Page_Load(object sender, EventArgs e) string key = item.Attributes["ResourceKey"]; if (key != null) { - item.Text = Localization.GetString(key+".Text", ResourceFile); + item.Text = Localization.GetString(key + ".Text", ResourceFile); } } foreach (ListItem item in rblUseTemplate.Items) @@ -81,8 +81,8 @@ protected void rblFrom_SelectedIndexChanged(object sender, EventArgs e) // tbTemplateName.Text = Path.GetFileNameWithoutExtension(ddlTemplate.Items[0].Value); //} - - foreach (var item in GithubTemplateUtils.GetTemplateList(ModuleContext.PortalId).Where(t=> t.Type == Components.Github.TypeEnum.Dir).OrderBy(t => t.Name)) + + foreach (var item in GithubTemplateUtils.GetTemplateList(ModuleContext.PortalId).Where(t => t.Type == Components.Github.TypeEnum.Dir).OrderBy(t => t.Name)) { ddlTemplate.Items.Add(new ListItem(item.Name, item.Path)); } @@ -494,9 +494,15 @@ private bool IsTabWithModuleWithSameMainModule(int tabId, int datamoduleId) ModuleInfo moduleInfo = item.Value; if (moduleInfo.ModuleDefinition.FriendlyName == App.Config.Opencontent) { - if (moduleInfo.OpenContentSettings().GetModuleId(moduleInfo.ModuleID) == datamoduleId) + try + { + if (moduleInfo.OpenContentSettings().GetModuleId(moduleInfo.ModuleID) == datamoduleId) + { + return true; + } + } + catch (Exception) { - return true; } } } @@ -517,7 +523,7 @@ private void ActivateDetailPage() } } - + } } \ No newline at end of file From 68cb4e6132b4b7c56f5a1e4354d9e2cdc54a79e1 Mon Sep 17 00:00:00 2001 From: Sacha Trauwaen Date: Thu, 13 Jun 2019 15:57:38 +0200 Subject: [PATCH 05/17] multi language imagex field --- OpenContent/Components/Alpaca/AlpacaEngine.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenContent/Components/Alpaca/AlpacaEngine.cs b/OpenContent/Components/Alpaca/AlpacaEngine.cs index 7847c2c0..621945fb 100644 --- a/OpenContent/Components/Alpaca/AlpacaEngine.cs +++ b/OpenContent/Components/Alpaca/AlpacaEngine.cs @@ -161,12 +161,12 @@ private void RegisterFields(bool bootstrap) string apikey = App.Services.CreateGlobalSettingsRepository(PortalId).GetGoogleApiKey(); ClientResourceManager.RegisterScript(Page, "//maps.googleapis.com/maps/api/js?v=3.exp&libraries=places" + (string.IsNullOrEmpty(apikey) ? "" : "&key=" + apikey), FileOrder.Js.DefaultPriority); } - if (allFields || fieldTypes.ContainsAny("imagecropper", "imagecrop", "imagecrop2", "imagex")) + if (allFields || fieldTypes.ContainsAny("imagecropper", "imagecrop", "imagecrop2", "imagex", "mlimagex")) { ClientResourceManager.RegisterScript(Page, "~/DesktopModules/OpenContent/js/cropper/cropper.js", FileOrder.Js.DefaultPriority); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/cropper/cropper.css", FileOrder.Css.DefaultPriority); } - if (allFields || fieldTypes.ContainsAny("select2", "image2", "file2", "url2", "mlimage2", "mlfile2", "mlurl2", "mlfolder2", "imagecrop2", "role2", "user2", "imagex")) + if (allFields || fieldTypes.ContainsAny("select2", "image2", "file2", "url2", "mlimage2", "mlfile2", "mlurl2", "mlfolder2", "imagecrop2", "role2", "user2", "imagex", "mlimagex")) { ClientResourceManager.RegisterScript(Page, "~/DesktopModules/OpenContent/js/select2/select2.js", FileOrder.Js.DefaultPriority); ClientResourceManager.RegisterStyleSheet(Page, "~/DesktopModules/OpenContent/js/select2/select2.css", FileOrder.Css.DefaultPriority); From 28a866784123901d8637939046c7957f7bdf91cc Mon Sep 17 00:00:00 2001 From: Sacha Trauwaen Date: Tue, 18 Jun 2019 10:18:44 +0200 Subject: [PATCH 06/17] full export/import --- .../ShareTemplate.ascx.resx | 15 + OpenContent/Components/Export/FullExport.cs | 450 ++++++++++++++++++ OpenContent/Components/Export/JsonTraverse.cs | 72 +++ OpenContent/OpenContent.csproj | 4 + OpenContent/ShareTemplate.ascx | 56 +++ OpenContent/ShareTemplate.ascx.cs | 55 ++- OpenContent/ShareTemplate.ascx.designer.cs | 298 +++++++++--- 7 files changed, 871 insertions(+), 79 deletions(-) create mode 100644 OpenContent/Components/Export/FullExport.cs create mode 100644 OpenContent/Components/Export/JsonTraverse.cs diff --git a/OpenContent/App_LocalResources/ShareTemplate.ascx.resx b/OpenContent/App_LocalResources/ShareTemplate.ascx.resx index 71be231c..cc0617ae 100644 --- a/OpenContent/App_LocalResources/ShareTemplate.ascx.resx +++ b/OpenContent/App_LocalResources/ShareTemplate.ascx.resx @@ -153,4 +153,19 @@ From Template + + Import Data + + + Import Settings + + + Import Template + + + Import Additional Data + + + Create Backup + \ No newline at end of file diff --git a/OpenContent/Components/Export/FullExport.cs b/OpenContent/Components/Export/FullExport.cs new file mode 100644 index 00000000..2e814177 --- /dev/null +++ b/OpenContent/Components/Export/FullExport.cs @@ -0,0 +1,450 @@ +using DotNetNuke.Common.Utilities; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Entities.Portals; +using DotNetNuke.Services.FileSystem; +using Newtonsoft.Json.Linq; +using Satrabel.OpenContent.Components.Datasource; +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Web; +using System.Web.Hosting; + +namespace Satrabel.OpenContent.Components.Export +{ + public class FullExport + { + private JObject Files; + public FullExport(int tabId, int moduleId) + { + PortalSettings = PortalSettings.Current; + PortalId = PortalSettings.PortalId; + TabId = tabId; + ModuleId = moduleId; + ExportDirectory = HostingEnvironment.MapPath("~/" + PortalSettings.HomeDirectory + "OpenContent/Export/"); + ModuleExportDirectory = ExportDirectory + ModuleId.ToString() + "\\"; + ImportDirectory = HostingEnvironment.MapPath("~/" + PortalSettings.HomeDirectory + "OpenContent/Import/"); + ModuleImportDirectory = ImportDirectory + ModuleId.ToString() + "\\"; + } + public int PortalId { get; private set; } + public int TabId { get; private set; } + public int ModuleId { get; private set; } + + public PortalSettings PortalSettings { get; private set; } + private string ExportDirectory { get; set; } + private string ModuleExportDirectory { get; set; } + + private string ImportDirectory { get; set; } + private string ModuleImportDirectory { get; set; } + + + public string Export() + { + if (Directory.Exists(ModuleExportDirectory)) + Directory.Delete(ModuleExportDirectory, true); + + Directory.CreateDirectory(ModuleExportDirectory); + + Files = new JObject(); + var module = OpenContentModuleConfig.Create(ModuleId, TabId, PortalSettings); + IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); + var dsContext = OpenContentUtils.CreateDataContext(module); + var alpaca = ds.GetAlpaca(dsContext, true, true, false); + if (module.IsListMode()) + { + var dsItems = ds.GetAll(dsContext, null); + var arr = new JArray(); + foreach (var dsItem in dsItems.Items) + { + var json = dsItem.Data; + ExportTraverse(alpaca, json); + arr.Add(json); + } + SaveData(arr); + } + else + { + dsContext.Single = true; + var dsItem = ds.Get(dsContext, null); + var json = dsItem.Data; + ExportTraverse(alpaca, json); + SaveData(json); + } + + // additional data + foreach (var item in module.Settings.Manifest.AdditionalDataDefinition) + { + alpaca = ds.GetDataAlpaca(dsContext, true, true, false, item.Key); + var dsItem = ds.GetData(dsContext, item.Value.ScopeType, item.Key); + if (dsItem != null) + { + var json = dsItem.Data; + ExportTraverse(alpaca, json); + SaveData(json, item.Key); + } + } + + // save settings + SaveSettings(module.Settings); + // zip template + string startPath = module.Settings.Template.Key.TemplateDir.PhysicalFullDirectory; + string zipPath = ModuleExportDirectory + Path.GetFileName(module.Settings.Template.Key.Folder) + ".zip"; + if (File.Exists(zipPath)) File.Delete(zipPath); + ZipFile.CreateFromDirectory(startPath, zipPath); + + // zip all + string allStartPath = ModuleExportDirectory; + string allZipPath = ExportDirectory + Path.GetFileName(module.Settings.Template.Key.Folder) + "-" + PortalId + "-" + TabId + "-" + ModuleId + "-" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm") + ".zip"; + if (File.Exists(allZipPath)) File.Delete(allZipPath); + ZipFile.CreateFromDirectory(allStartPath, allZipPath); + //Directory.Delete(ModuleExportDirectory, true); + return allZipPath; + } + + private void SaveSettings(OpenContentSettings settings) + { + var set = new JObject(); + set["Name"] = Path.GetFileName(settings.Template.Key.Folder); + set["PortalId"] = PortalId; + set["TabId"] = TabId; + set["ModuleId"] = ModuleId; + set["Template"] = settings.Template.Key.ToString(); + if (!string.IsNullOrEmpty(settings.Data)) + { + set["Settings"] = JObject.Parse(settings.Data); + } + set["Query"] = settings.Query; + set["Files"] = Files; + File.WriteAllText(ModuleExportDirectory + "export.json", set.ToString()); + } + + //private string TokenizePath(string path) + //{ + // return path.Replace("Portals/" + PortalId + "/", "Portals/[PORTALID]/") + // .Replace("/OpenContent/Files/" + ModuleId + "/", "/OpenContent/Files/[MODULEID]/") + // .Replace("/OpenContent/Cropped/" + ModuleId + "/", "/OpenContent/Cropped/[MODULEID]/"); + //} + + private void SaveData(JToken json, string key = "data") + { + File.WriteAllText(ModuleExportDirectory + key + ".json", json.ToString()); + } + private void ExportTraverse(JObject alpaca, JToken json) + { + JsonTraverse.Traverse(json.DeepClone(), alpaca["schema"] as JObject, alpaca["options"] as JObject, (data, schema, options) => + { + var optionsType = options?.Value("type"); + if (optionsType == "image" || optionsType == "file") + { + SaveFile(data.ToString()); + } + else if (optionsType == "mlimage" || optionsType == "mlfile") + { + if (json is JObject) + { + foreach (var item in (data as JObject).Children()) + { + SaveFile(item.Value.ToString()); + } + } + } + else if (optionsType == "imagex") + { + SaveFile(data?["url"].ToString()); + SaveFile(data?["cropUrl"].ToString()); + } + else if (optionsType == "mlimagex") + { + if (json is JObject) + { + foreach (var item in (data as JObject).Children()) + { + if (item.Type == JTokenType.Object) + { + SaveFile(item.Value?["url"].ToString()); + SaveFile(item.Value?["cropUrl"].ToString()); + } + } + } + } + else if (optionsType == "file2") + { + SaveFile(data.Value()); + } + else if (optionsType == "mlfile2") + { + if (json is JObject) + { + foreach (var item in (data as JObject).Children()) + { + SaveFile(item.Value()); + } + } + } + }); + } + private JToken ImportTraverse(JObject alpaca, JToken json) + { + var ModuleFilesFolder = /*PortalSettings.HomeDirectory +*/ "OpenContent/Files/" + ModuleId.ToString() + "/"; + var ModuleCroppedFolder = /*PortalSettings.HomeDirectory +*/ "OpenContent/Cropped/" + ModuleId.ToString() + "/"; + return JsonTraverse.Traverse(json.DeepClone(), alpaca["schema"] as JObject, alpaca["options"] as JObject, (data, schema, options) => + { + var optionsType = options?.Value("type"); + if (optionsType == "image" || optionsType == "file") + { + return ImportFile(data, ModuleFilesFolder); + } + else if (optionsType == "mlimage" || optionsType == "mlfile") + { + if (json is JObject) + { + var newObj = new JObject(); + foreach (var item in (data as JObject).Children()) + { + newObj[item.Name] = ImportFile(item.Value, ModuleFilesFolder); + } + return newObj; + } + } + else if (optionsType == "imagex") + { + ImportFile(data, "url", ModuleFilesFolder, true); + ImportFile(data, "cropUrl", ModuleCroppedFolder); + } + else if (optionsType == "mlimagex") + { + if (json is JObject) + { + foreach (var item in (data as JObject).Children()) + { + ImportFile(item.Value, "url", ModuleFilesFolder, true); + ImportFile(item.Value, "cropUrl", ModuleCroppedFolder); + } + } + } + else if (optionsType == "file2") + { + var filename = Files[data.ToString()].ToString(); + return ImportFileId(filename, ModuleFilesFolder); + } + else if (optionsType == "mlfile2") + { + if (json is JObject) + { + var newObj = new JObject(); + foreach (var item in (data as JObject).Children()) + { + var filename = Files[data.ToString()].ToString(); + newObj[item.Name] = ImportFileId(filename, ModuleFilesFolder); + } + return newObj; + } + } + return data; + }); + } + + private void ImportFile(JToken data, string field, string ModuleFilesFolder, bool setId = false) + { + var filename = Path.GetFileName(data[field].ToString()); + data[field] = new JValue(PortalSettings.HomeDirectory + ModuleFilesFolder + filename); + var file = ImportFile(filename, ModuleFilesFolder); + if (setId && file!= null) + { + data["id"] = new JValue(file.FileId.ToString()); + } + } + + private JToken ImportFile(JToken data, string ModuleFilesFolder) + { + var filename = Path.GetFileName(data.ToString()); + ImportFile(filename, ModuleFilesFolder); + return new JValue(PortalSettings.HomeDirectory + ModuleFilesFolder + filename); + } + + private JToken ImportFileId(string filename, string ModuleFilesFolder) + { + var file = ImportFile(filename, ModuleFilesFolder); + if (file != null) + return new JValue(file.FileId.ToString()); + else + return null; + } + + private IFileInfo ImportFile(string filename, string folder) + { + if (string.IsNullOrEmpty(filename)) return null; + var sourceFilename = ModuleImportDirectory + filename; + //var destinationDirectory = HostingEnvironment.MapPath("~/" + folder); + //var destinationFilename = destinationDirectory + filename; + + if (!File.Exists(sourceFilename)) return null; + + return AddFile(filename, folder, sourceFilename); + + + //if (!Directory.Exists(destinationDirectory)) + // Directory.CreateDirectory(destinationDirectory); + // File.Copy(sourceFilename, destinationFilename, true); + } + + private IFileInfo AddFile(string filename, string folder, string sourceFilename) + { + var fileManager = FileManager.Instance; + var folderManager = FolderManager.Instance; + + var f = folderManager.GetFolder(PortalId, folder); + if (f == null) + { + f = folderManager.AddFolder(PortalId, folder); + } + if (sourceFilename.IndexOf('?') > 0) + { + sourceFilename = sourceFilename.Substring(0, sourceFilename.IndexOf('?')); + } + if (filename.IndexOf('?') > 0) + { + filename = filename.Substring(0, filename.IndexOf('?')); + } + return fileManager.AddFile(f, filename, File.OpenRead(sourceFilename), true); + } + + private void SaveFile(string url) + { + if (string.IsNullOrEmpty(url)) return; + + if ( url.IndexOf('?')> 0) + { + url = url.Substring(0, url.IndexOf('?')); + } + + var sourceFilename = HostingEnvironment.MapPath("~/" + url); + var destinationFilename = ModuleExportDirectory + Path.GetFileName(url); + if (File.Exists(sourceFilename)) + { + File.Copy(sourceFilename, destinationFilename, true); + if (Files[url] == null) + Files.Add(url, Path.GetFileName(url)); + } + } + private void SaveFile(int fileId) + { + var fileManager = FileManager.Instance; + var file = fileManager.GetFile(fileId); + + var sourceFilename = file.PhysicalPath; + var destinationFilename = ModuleExportDirectory + file.FileName; + if (File.Exists(sourceFilename)) + { + File.Copy(sourceFilename, destinationFilename, true); + if (Files[fileId.ToString()] == null) + Files.Add(fileId.ToString(), file.FileName); + } + } + public void Import(string filename, bool importTemplate, bool importData, bool importAdditionalData, bool importSettings) + { + // unzip all + string allStartPath = ModuleImportDirectory; + string allZipPath = ImportDirectory + filename; + + if (Directory.Exists(allStartPath)) + Directory.Delete(allStartPath, true); + + ZipFile.ExtractToDirectory(allZipPath, allStartPath); + + var export = JObject.Parse(File.ReadAllText(ModuleImportDirectory + "export.json")); + + Files = export["Files"] as JObject; + // unzip template + if (importTemplate) + { + string startPath = HostingEnvironment.MapPath("~/" + PortalSettings.HomeDirectory + "OpenContent/Templates/" + export["Name"]); + if (!Directory.Exists(startPath)) + Directory.CreateDirectory(startPath); + string zipPath = ModuleImportDirectory + export["Name"] + ".zip"; + + if (Directory.Exists(startPath)) + Directory.Delete(startPath, true); + + ZipFile.ExtractToDirectory(zipPath, startPath); + } + if (importSettings) + { + ModuleController mc = new ModuleController(); + mc.UpdateModuleSetting(ModuleId, "template", export["Template"].ToString() + .Replace("Portals/" + export["PortalId"] + "/", "Portals/" + PortalId + "/")); + //.Replace("[PORTALID]", PortalId.ToString())); + if (export["Settings"] != null) + { + mc.UpdateModuleSetting(ModuleId, "data", export["Settings"].ToString()); + } + mc.UpdateModuleSetting(ModuleId, "query", export["Query"].ToString()); + + DataCache.ClearCache(); + } + var module = OpenContentModuleConfig.Create(ModuleId, TabId, PortalSettings); + IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); + var dsContext = OpenContentUtils.CreateDataContext(module); + if (importData) + { + var alpaca = ds.GetAlpaca(dsContext, true, true, false); + var data = JToken.Parse(File.ReadAllText(ModuleImportDirectory + "data.json")); + if (module.IsListMode()) + { + var dataList = ds.GetAll(dsContext, null).Items; + foreach (var item in dataList) + { + ds.Delete(dsContext, item); + } + if (data is JArray) + { + foreach (JObject json in data) + { + ds.Add(dsContext, ImportTraverse(alpaca, json)); + } + } + } + else + { + var dsItem = ds.Get(dsContext, null); + data = ImportTraverse(alpaca, data); + if (dsItem == null) + { + ds.Add(dsContext, data); + } + else + { + ds.Update(dsContext, dsItem, data); + } + } + } + + if (importAdditionalData) + { + foreach (var item in module.Settings.Manifest.AdditionalDataDefinition) + { + var alpaca = ds.GetDataAlpaca(dsContext, true, true, false, item.Key); + var dataFile = ModuleImportDirectory + item.Key + ".json"; + if (File.Exists(dataFile)) + { + var data = JToken.Parse(File.ReadAllText(dataFile)); + + var dsItem = ds.GetData(dsContext, item.Value.ScopeType, item.Key); + data = ImportTraverse(alpaca, data); + if (dsItem == null) + { + ds.AddData(dsContext, item.Value.ScopeType, item.Key, data); + } + else + { + ds.UpdateData(dsContext, dsItem, data); + } + } + } + } + //Directory.Delete(allStartPath, true); + } + } +} \ No newline at end of file diff --git a/OpenContent/Components/Export/JsonTraverse.cs b/OpenContent/Components/Export/JsonTraverse.cs new file mode 100644 index 00000000..bace37ee --- /dev/null +++ b/OpenContent/Components/Export/JsonTraverse.cs @@ -0,0 +1,72 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Satrabel.OpenContent.Components.Export +{ + public class JsonTraverse + { + public static JToken Traverse(JToken data, JObject schema, JObject options, Func callback) + { + var json = callback(data, schema, options); + if (json is JArray) + { + JObject sch = schema?["items"] as JObject; + JObject opt = options?["items"] as JObject; + var array = json as JArray; + var newArray = new JArray(); + foreach (var arrayItem in array) + { + var res = Traverse(arrayItem, sch, opt, callback); + newArray.Add(res); + } + json = newArray; + } + else if (json is JObject) + { + var obj = json as JObject; + foreach (var child in json.Children().ToList()) + { + var sch = schema?["properties"]?[child.Name] as JObject; + var opt = options?["fields"]?[child.Name] as JObject; + child.Value = Traverse(child.Value, sch, opt, callback); + } + } + else if (json is JValue) + { + } + return json; + } + + + public static void Traverse(JToken data, JObject schema, JObject options, Action callback) + { + callback(data, schema, options); + if (data is JArray) + { + JObject sch = schema?["items"] as JObject; + JObject opt = options?["items"] as JObject; + var array = data as JArray; + foreach (var arrayItem in array) + { + Traverse(arrayItem, sch, opt, callback); + } + } + else if (data is JObject) + { + var obj = data as JObject; + foreach (var child in data.Children().ToList()) + { + var sch = schema?["properties"]?[child.Name] as JObject; + var opt = options?["fields"]?[child.Name] as JObject; + Traverse(child.Value, sch, opt, callback); + } + } + else if (data is JValue) + { + } + } + } +} \ No newline at end of file diff --git a/OpenContent/OpenContent.csproj b/OpenContent/OpenContent.csproj index a2fd8c43..09f49e15 100644 --- a/OpenContent/OpenContent.csproj +++ b/OpenContent/OpenContent.csproj @@ -126,6 +126,8 @@ + + False @@ -175,6 +177,8 @@ + + diff --git a/OpenContent/ShareTemplate.ascx b/OpenContent/ShareTemplate.ascx index c47e874f..41f3a672 100644 --- a/OpenContent/ShareTemplate.ascx +++ b/OpenContent/ShareTemplate.ascx @@ -24,6 +24,8 @@ + + @@ -107,6 +109,60 @@ + +
+
+
+
    +
  • + +
  • +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
    +
  • + +
  • +
+
+
+ \n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["container-array"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.item) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.item); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.item) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["container-object-item"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["container-object"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.item) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.item); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.item) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["container-table-item"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, self=this, helperMissing=helpers.helperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["container-table"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing, blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - -function program3(depth0,data) { - - var buffer = "", stack1; - buffer += "\n " - + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.value)),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) - + "\n "; - return buffer; - } - -function program5(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n\n "; - stack1 = (helper = helpers.item || (depth0 && depth0.item),options={hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data},helper ? helper.call(depth0, "tr", options) : helperMissing.call(depth0, "item", "tr", options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["container-tablerow-item"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["container-tablerow"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.item) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.item); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.item) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["container"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1; - buffer += "\n "; - stack1 = ((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.label)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } -function program2(depth0,data) { - - var stack1; - return escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.labelClass)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)); - } - -function program4(depth0,data) { - - var buffer = "", stack1; - buffer += "\n

\n \n "; - stack1 = ((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.helper)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n

\n "; - return buffer; - } -function program5(depth0,data) { - - var stack1; - return escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.helperClass)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)); - } - -function program7(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control-any"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, helperMissing=helpers.helperMissing; - - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control-checkbox"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, helperMissing=helpers.helperMissing; - - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control-image"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression; - - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control-radio"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, functionType="function", self=this, helperMissing=helpers.helperMissing; - -function program1(depth0,data,depth1) { - - var buffer = "", stack1, helper, options; - buffer += "\n "; - stack1 = (helper = helpers.compare || (depth0 && depth0.compare),options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data},helper ? helper.call(depth0, (depth0 && depth0.value), (depth1 && depth1.data), options) : helperMissing.call(depth0, "compare", (depth0 && depth0.value), (depth1 && depth1.data), options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = "", stack1, helper; - buffer += "\n "; - if (helper = helpers.text) { stack1 = helper.call(depth0, {hash:{},data:data}); } - else { helper = (depth0 && depth0.text); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control-select"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, functionType="function", self=this, helperMissing=helpers.helperMissing; - -function program1(depth0,data,depth1) { - - var buffer = "", stack1, helper, options; - buffer += "\n "; - stack1 = (helper = helpers.compare || (depth0 && depth0.compare),options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data},helper ? helper.call(depth0, (depth0 && depth0.value), (depth1 && depth1.data), options) : helperMissing.call(depth0, "compare", (depth0 && depth0.value), (depth1 && depth1.data), options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = "", stack1, helper; - buffer += "\n "; - if (helper = helpers.text) { stack1 = helper.call(depth0, {hash:{},data:data}); } - else { helper = (depth0 && depth0.text); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control-text"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, functionType="function"; - - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control-textarea"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, functionType="function"; - - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control-url"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this; - -function program1(depth0,data) { - - var buffer = "", stack1; - buffer += "target=\"" - + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.anchorTarget)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) - + "\""; - return buffer; - } - -function program3(depth0,data) { - - var stack1; - return escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.anchorTitle)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)); - } - -function program5(depth0,data) { - - var stack1, helper; - if (helper = helpers.data) { stack1 = helper.call(depth0, {hash:{},data:data}); } - else { helper = (depth0 && depth0.data); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } - return escapeExpression(stack1); - } - -function program7(depth0,data) { - - var buffer = "", stack1; - buffer += "\n " - + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.anchorTitle)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) - + "\n "; - return buffer; - } - -function program9(depth0,data) { - - var buffer = "", stack1, helper; - buffer += "\n "; - if (helper = helpers.data) { stack1 = helper.call(depth0, {hash:{},data:data}); } - else { helper = (depth0 && depth0.data); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } - buffer += escapeExpression(stack1) - + "\n "; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["control"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1, helper; - buffer += "\n \n "; - return buffer; - } -function program2(depth0,data) { - - var stack1; - return escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.labelClass)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)); - } - -function program4(depth0,data) { - - var buffer = ""; - return buffer; - } - -function program6(depth0,data) { - - var buffer = "", stack1; - buffer += "\n

\n \n "; - stack1 = ((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.helper)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n

\n "; - return buffer; - } -function program7(depth0,data) { - - var stack1; - return escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.helperClass)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)); - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-display"] = this["HandlebarsPrecompiled"]["web-display"] || {}; -this["HandlebarsPrecompiled"]["web-display"]["form"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing, blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - -function program3(depth0,data,depth1) { - - var buffer = "", stack1; - buffer += "\n "; - stack1 = helpers.each.call(depth0, ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.buttons), {hash:{},inverse:self.noop,fn:self.programWithDepth(4, program4, data, depth1),data:data}); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } -function program4(depth0,data,depth2) { - - var buffer = "", stack1, helper, options; - buffer += "\n \n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = "", stack1; - buffer += "\n \n "; - return buffer; - } - -function program4(depth0,data) { - - var stack1, helper; - if (helper = helpers.label) { stack1 = helper.call(depth0, {hash:{},data:data}); } - else { helper = (depth0 && depth0.label); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } - if(stack1 || stack1 === 0) { return stack1; } - else { return ''; } - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-array-item"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing, helperMissing=helpers.helperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n
\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.arrayActionbar) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.arrayActionbar); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.arrayActionbar) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n
\n
\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.itemField) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.itemField); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.itemField) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n
\n
\n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = ""; - return buffer; - } - -function program4(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n "; - stack1 = (helper = helpers.compare || (depth0 && depth0.compare),options={hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data},helper ? helper.call(depth0, (depth0 && depth0.actionbarStyle), "right", options) : helperMissing.call(depth0, "compare", (depth0 && depth0.actionbarStyle), "right", options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } -function program5(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n
\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.itemField) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.itemField); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.itemField) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n
\n
\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.arrayActionbar) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.arrayActionbar); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.arrayActionbar) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n
\n
\n "; - return buffer; - } - -function program7(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n
\n\n "; - stack1 = (helper = helpers.compare || (depth0 && depth0.compare),options={hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data},helper ? helper.call(depth0, (depth0 && depth0.actionbarStyle), "top", options) : helperMissing.call(depth0, "compare", (depth0 && depth0.actionbarStyle), "top", options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.itemField) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.itemField); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.itemField) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - stack1 = (helper = helpers.compare || (depth0 && depth0.compare),options={hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data},helper ? helper.call(depth0, (depth0 && depth0.actionbarStyle), "bottom", options) : helperMissing.call(depth0, "compare", (depth0 && depth0.actionbarStyle), "bottom", options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n
\n "; - return buffer; - } -function program8(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.arrayActionbar) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.arrayActionbar); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.arrayActionbar) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-array-toolbar"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing; - -function program1(depth0,data) { - - - return " btn-group"; - } - -function program3(depth0,data,depth1) { - - var buffer = "", stack1, helper, options; - buffer += "\n\n "; - stack1 = (helper = helpers.compare || (depth1 && depth1.compare),options={hash:{},inverse:self.noop,fn:self.programWithDepth(4, program4, data, depth0),data:data},helper ? helper.call(depth0, (depth1 && depth1.toolbarStyle), "link", options) : helperMissing.call(depth0, "compare", (depth1 && depth1.toolbarStyle), "link", options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - stack1 = (helper = helpers.compare || (depth1 && depth1.compare),options={hash:{},inverse:self.noop,fn:self.programWithDepth(6, program6, data, depth0, depth1),data:data},helper ? helper.call(depth0, (depth1 && depth1.toolbarStyle), "button", options) : helperMissing.call(depth0, "compare", (depth1 && depth1.toolbarStyle), "button", options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - return buffer; - } -function program4(depth0,data,depth1) { - - var buffer = "", stack1; - buffer += "\n "; - stack1 = ((stack1 = (depth1 && depth1.label)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } - -function program6(depth0,data,depth1,depth2) { - - var buffer = "", stack1; - buffer += "\n \n "; - return buffer; - } -function program7(depth0,data,depth1) { - - var buffer = "", stack1; - buffer += "\n \n "; - return buffer; - } - -function program9(depth0,data,depth1) { - - var stack1; - stack1 = ((stack1 = (depth1 && depth1.label)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); - if(stack1 || stack1 === 0) { return stack1; } - else { return ''; } - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-array"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - -function program3(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n\n "; - options={hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data} - if (helper = helpers.item) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.item); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.item) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-object-item"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-object"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.item) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.item); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.item) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-table-item"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, self=this, helperMissing=helpers.helperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-table"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, self=this, helperMissing=helpers.helperMissing, blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - -function program3(depth0,data) { - - var buffer = "", stack1; - buffer += "\n " - + escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.value)),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) - + "\n "; - return buffer; - } - -function program5(depth0,data) { - - - return "\n Actions\n "; - } - -function program7(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n\n "; - stack1 = (helper = helpers.item || (depth0 && depth0.item),options={hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data},helper ? helper.call(depth0, "tr", options) : helperMissing.call(depth0, "item", "tr", options)); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-tablerow-item"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += "\n"; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container-tablerow"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.item) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.item); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.item) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } -function program2(depth0,data) { - - var buffer = ""; - return buffer; - } - -function program4(depth0,data) { - - var buffer = "", stack1, helper, options; - buffer += "\n
\n "; - options={hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data} - if (helper = helpers.arrayActionbar) { stack1 = helper.call(depth0, options); } - else { helper = (depth0 && depth0.arrayActionbar); stack1 = typeof helper === functionType ? helper.call(depth0, options) : helper; } - if (!helpers.arrayActionbar) { stack1 = blockHelperMissing.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n
\n "; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["container"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1; - buffer += "\n "; - stack1 = ((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.label)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer; - } -function program2(depth0,data) { - - var stack1; - return escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.labelClass)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)); - } - -function program4(depth0,data) { - - var buffer = "", stack1; - buffer += "\n

\n \n "; - stack1 = ((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.helper)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n

\n "; - return buffer; - } -function program5(depth0,data) { - - var stack1; - return escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.options)),stack1 == null || stack1 === false ? stack1 : stack1.helperClass)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)); - } - -function program7(depth0,data) { - - var buffer = ""; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["control-any"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this; - -function program1(depth0,data) { - - - return "readonly=\"readonly\""; - } - -function program3(depth0,data) { - - var buffer = "", stack1, helper; - buffer += "name=\""; - if (helper = helpers.name) { stack1 = helper.call(depth0, {hash:{},data:data}); } - else { helper = (depth0 && depth0.name); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; } - buffer += escapeExpression(stack1) - + "\""; - return buffer; - } - -function program5(depth0,data) { - - var buffer = "", stack1; - buffer += "data-" - + escapeExpression(((stack1 = (data == null || data === false ? data : data.key)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) - + "=\"" - + escapeExpression((typeof depth0 === functionType ? depth0.apply(depth0) : depth0)) - + "\""; - return buffer; - } - - buffer += ""; - return buffer; - }; -this["HandlebarsPrecompiled"] = this["HandlebarsPrecompiled"] || {}; -this["HandlebarsPrecompiled"]["web-edit"] = this["HandlebarsPrecompiled"]["web-edit"] || {}; -this["HandlebarsPrecompiled"]["web-edit"]["control-checkbox"] = function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; - -function program1(depth0,data,depth1) { - - var buffer = "", stack1; - buffer += "\n\n "; - stack1 = helpers.each.call(depth0, (depth0 && depth0.checkboxOptions), {hash:{},inverse:self.noop,fn:self.programWithDepth(2, program2, data, depth1),data:data}); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n "; - return buffer; - } -function program2(depth0,data,depth2) { - - var buffer = "", stack1, helper; - buffer += "\n\n
\n\n
");e(i.field).before(a),i.domEl=e("
"),i.setup(),i._render(function(){e(a).before(i.domEl.children()),e(a).remove(),i._oldFieldEl&&e(i._oldFieldEl).remove(),t&&t()})},applyStyle:function(e,t){this.view.applyStyle(e,t)},fireCallback:function(e,t,i,a,n,r){this.view.fireCallback(this,e,t,i,a,n,r)},getFieldEl:function(){return this.field},getId:function(){return this.id},getParent:function(){return this.parent},isTopLevel:function(){return t.isEmpty(this.parent)},getValue:function(){var e=this,t=this.data;return t=e.ensureProperType(t)},setValue:function(e){this.data=e,this.updateObservable(),this.triggerUpdate()},setDefault:function(){},getTemplateDescriptor:function(){return this.templateDescriptor},setTemplateDescriptor:function(e){this.templateDescriptor=e},displayMessage:function(i){var a=this;i&&t.isObject(i)&&(i=[i]),i&&t.isString(i)&&(i=[{id:"custom",message:i}]),e(this.getFieldEl()).children(".alpaca-message").remove(),a.fireCallback("removeMessages"),i&&i.length>0&&e.each(i,function(i,n){var r=!1;a.hideInitValidationError&&(r=!0);var o=a.view.getTemplateDescriptor("message");if(o){var s=t.tmpl(o,{id:n.id,message:n.message,view:a.view});s.addClass("alpaca-message"),r&&s.addClass("alpaca-message-hidden"),e(a.getFieldEl()).append(s)}a.fireCallback("addMessage",i,n.id,n.message,r)})},refreshValidationState:function(e,i){var a=this,n=[],r=[],o=function(e,i){return function(a){t.compileValidationContext(e,function(e){i.push(e),a()})}};if(e){var s=function(e,t){if(e.isValidationParticipant()){if(e.children&&e.children.length>0)for(var i=0;idisplayReadonly attribute set to false, the read-only field will not appear.",type:"boolean","default":!1},required:{title:"Required",description:"Indicates whether the field's value is required. If set to true, the field must take on a valid value and cannnot be left empty or unassigned.",type:"boolean","default":!1},"default":{title:"Default",description:"The default value to be assigned for this property. If the data for the field is empty or not provided, this default value will be plugged in for you. Specify a default value when you want to pre-populate the field's value ahead of time.",type:"any"},type:{title:"Type",description:"Data type of the property.",type:"string",readonly:!0},format:{title:"Format",description:"Data format of the property.",type:"string"},disallow:{title:"Disallowed Values",description:"List of disallowed values for the property.",type:"array"},dependencies:{title:"Dependencies",description:"List of property dependencies.",type:"array"}}};return this.getType&&!t.isValEmpty(this.getType())&&(e.properties.type["default"]=this.getType(),e.properties.type["enum"]=[this.getType()]),e},getOptionsForSchema:function(){return{fields:{title:{helper:"Field short description",type:"text"},description:{helper:"Field detailed description",type:"textarea"},readonly:{helper:"Field will be read only if checked",rightLabel:"This field is read-only",type:"checkbox"},required:{helper:"Field value must be set if checked",rightLabel:"This field is required",type:"checkbox"},"default":{helper:"Field default value",type:"textarea"},type:{helper:"Field data type",type:"text"},format:{type:"select",dataSource:function(e){for(var i in t.defaultFormatFieldMapping)this.selectOptions.push({value:i,text:i});e()}},disallow:{helper:"Disallowed values for the field",itemLabel:"Value",type:"array"},dependencies:{helper:"Field Dependencies",multiple:!0,size:3,type:"select",dataSource:function(e,t){if(e.parent&&e.parent.schemaParent&&e.parent.schemaParent.parent)for(var i in e.parent.schemaParent.parent.childrenByPropertyId)i!=e.parent.schemaParent.propertyId&&e.selectOptions.push({value:i,text:i});t&&t()}}}}},getSchemaOfOptions:function(){var e={title:"Options for "+this.getTitle(),description:this.getDescription()+" (Options)",type:"object",properties:{form:{},id:{title:"Field Id",description:"Unique field id. Auto-generated if not provided.",type:"string"},type:{title:"Field Type",description:"Field type.",type:"string","default":this.getFieldType(),readonly:!0},validate:{title:"Validation",description:"Field validation is required if true.",type:"boolean","default":!0},showMessages:{title:"Show Messages",description:"Display validation messages if true.",type:"boolean","default":!0},disabled:{title:"Disabled",description:"Field will be disabled if true.",type:"boolean","default":!1},readonly:{title:"Readonly",description:"Field will be readonly if true.",type:"boolean","default":!1},hidden:{title:"Hidden",description:"Field will be hidden if true.",type:"boolean","default":!1},label:{title:"Label",description:"Field label.",type:"string"},helper:{title:"Helper",description:"Field help message.",type:"string"},fieldClass:{title:"CSS class",description:"Specifies one or more CSS classes that should be applied to the dom element for this field once it is rendered. Supports a single value, comma-delimited values, space-delimited values or values passed in as an array.",type:"string"},hideInitValidationError:{title:"Hide Initial Validation Errors",description:"Hide initial validation errors if true.",type:"boolean","default":!1},focus:{title:"Focus",description:"If true, the initial focus for the form will be set to the first child element (usually the first field in the form). If a field name or path is provided, then the specified child field will receive focus. For example, you might set focus to 'name' (selecting the 'name' field) or you might set it to 'client/name' which picks the 'name' field on the 'client' object.",type:"checkbox","default":!0},optionLabels:{title:"Enumerated Value Labels",description:"An array of string labels for items in the enum array",type:"array"},view:{title:"Override of the view for this field",description:"Allows for this field to be rendered with a different view (such as 'display' or 'create')",type:"string"}}};return this.isTopLevel()?e.properties.form={title:"Form",description:"Options for rendering the FORM tag.",type:"object",properties:{attributes:{title:"Form Attributes",description:"List of attributes for the FORM tag.",type:"object",properties:{id:{title:"Id",description:"Unique form id. Auto-generated if not provided.",type:"string"},action:{title:"Action",description:"Form submission endpoint",type:"string"},method:{title:"Method",description:"Form submission method","enum":["post","get"],type:"string"},rubyrails:{title:"Ruby On Rails",description:"Ruby on Rails Name Standard","enum":["true","false"],type:"string"},name:{title:"Name",description:"Form name",type:"string"},focus:{title:"Focus",description:"Focus Setting",type:"any"}}},buttons:{title:"Form Buttons",description:"Configuration for form-bound buttons",type:"object",properties:{submit:{type:"object",title:"Submit Button",required:!1},reset:{type:"object",title:"Reset button",required:!1}}},toggleSubmitValidState:{title:"Toggle Submit Valid State",description:"Toggle the validity state of the Submit button",type:"boolean","default":!0}}}:delete e.properties.form,e},getOptionsForOptions:function(){var e={type:"object",fields:{id:{type:"text",readonly:!0},type:{type:"text"},validate:{rightLabel:"Enforce validation",type:"checkbox"},showMessages:{rightLabel:"Show validation messages",type:"checkbox"},disabled:{rightLabel:"Disable this field",type:"checkbox"},hidden:{type:"checkbox",rightLabel:"Hide this field"},label:{type:"text"},helper:{type:"textarea"},fieldClass:{type:"text"},hideInitValidationError:{rightLabel:"Hide initial validation errors",type:"checkbox"},focus:{type:"checkbox",rightLabel:"Auto-focus first child field"},optionLabels:{type:"array",items:{type:"string"}},view:{type:"text"}}};return this.isTopLevel()&&(e.fields.form={type:"object",fields:{attributes:{type:"object",fields:{id:{type:"text",readonly:!0},action:{type:"text"},method:{type:"select"},name:{type:"text"}}}}}),e}}),t.registerMessages({disallowValue:"{0} are disallowed values.",notOptional:"This field is not optional."})}(jQuery),function(e){var t=e.alpaca;t.ControlField=t.Field.extend({onConstruct:function(){var t=this;this.isControlField=!0,this._getControlVal=function(i){var a=null;return this.control&&(a=e(this.control).val(),i&&(a=t.ensureProperType(a))),a}},setup:function(){var e=this;this.base();var i=e.resolveControlTemplateType();return i?void(this.controlDescriptor=this.view.getTemplateDescriptor("control-"+i,e)):t.throwErrorWithCallback("Unable to find template descriptor for control: "+e.getFieldType())},getControlEl:function(){return this.control},resolveControlTemplateType:function(){var e=this,t=!1,i=null,a=this;do if(a.getFieldType){var n=this.view.getTemplateDescriptor("control-"+a.getFieldType(),e);n?(i=a.getFieldType(),t=!0):a=a.constructor.ancestor.prototype}else t=!0;while(!t);return i},onSetup:function(){},isAutoFocusable:function(){return!0},getTemplateDescriptorId:function(){return"control"},renderFieldElements:function(i){var a=this;this.control=e(this.field).find("."+t.MARKER_CLASS_CONTROL_FIELD),this.control.removeClass(t.MARKER_CLASS_CONTROL_FIELD),a.prepareControlModel(function(e){a.beforeRenderControl(e,function(){a.renderControl(e,function(n){n&&(a.control.replaceWith(n),a.control=n,a.control.addClass(t.CLASS_CONTROL)),a.fireCallback("control"),a.afterRenderControl(e,function(){i()})})})})},prepareControlModel:function(e){var t={};t.id=this.getId(),t.name=this.name,t.options=this.options,t.schema=this.schema,t.data=this.data,t.required=this.isRequired(),t.view=this.view,e(t)},beforeRenderControl:function(e,t){t()},afterRenderControl:function(e,t){var i=this;i.firstUpdateObservableFire||"undefined"==typeof i.data||null==i.data||(i.firstUpdateObservableFire=!0,i.updateObservable()),t()},renderControl:function(e,i){var a=null;this.controlDescriptor&&(a=t.tmpl(this.controlDescriptor,e)),i(a)},postRender:function(e){this.base(function(){e()})},setDefault:function(){var e=t.isEmpty(this.schema["default"])?"":this.schema["default"];this.setValue(e)},_validateEnum:function(){if(this.schema["enum"]){var i=this.data;return i=this.getValue(),!this.isRequired()&&t.isValEmpty(i)?!0:e.inArray(i,this.schema["enum"])>-1?!0:!1}return!0},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateEnum();return i.invalidValueOfEnum={message:a?"":t.substituteTokens(this.view.getMessage("invalidValueOfEnum"),[this.schema["enum"].join(", "),this.data]),status:a},e&&i.invalidValueOfEnum.status},initEvents:function(){this.base(),this.control&&this.control.length>0&&this.initControlEvents()},initControlEvents:function(){var e=this,t=this.control;t.click(function(t){e.onClick.call(e,t),e.trigger("click",t)}),t.change(function(t){setTimeout(function(){e.onChange.call(e,t),e.triggerWithPropagation("change",t)},250)}),t.focus(function(t){e.suspendBlurFocus||(e.onFocus.call(e,t),e.trigger("focus",t))}),t.blur(function(t){e.suspendBlurFocus||(e.onBlur.call(e,t),e.trigger("blur",t))}),t.keypress(function(t){e.onKeyPress.call(e,t),e.trigger("keypress",t)}),t.keyup(function(t){e.onKeyUp.call(e,t),e.trigger("keyup",t)}),t.keydown(function(t){e.onKeyDown.call(e,t),e.trigger("keydown",t)})},onKeyPress:function(){var e=this,t=this.isValid();t||window.setTimeout(function(){e.refreshValidationState()},50)},onKeyDown:function(){},onKeyUp:function(){},onClick:function(){},disable:function(){this.base(),this.control&&this.control.length>0&&e(this.control).prop("disabled",!0)},enable:function(){this.base(),this.control&&this.control.length>0&&e(this.control).prop("disabled",!1)},getSchemaOfSchema:function(){return t.merge(this.base(),{properties:{"enum":{title:"Enumerated Values",description:"List of specific values for this property",type:"array"}}})},getOptionsForSchema:function(){return t.merge(this.base(),{fields:{"enum":{itemLabel:"Value",type:"array"}}})},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{name:{title:"Field Name",description:"Field Name.",type:"string"}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{name:{type:"text"}}})}}),t.registerMessages({invalidValueOfEnum:"This field should have one of the values in {0}. Current value is: {1}"})}(jQuery),function(e){var t=e.alpaca;t.ContainerField=t.Field.extend({onConstruct:function(){this.isContainerField=!0},isContainer:function(){return!0},getContainerEl:function(){return this.container},getTemplateDescriptorId:function(){return"container"},resolveContainerTemplateType:function(){var e=!1,t=null,i=this;do if(i.getFieldType){var a=this.view.getTemplateDescriptor("container-"+i.getFieldType(),this);a?(t=i.getFieldType(),e=!0):i=i.constructor.ancestor.prototype}else e=!0;while(!e);return t},resolveContainerItemTemplateType:function(){var e=!1,t=null,i=this;do if(i.getFieldType){var a=this.view.getTemplateDescriptor("container-"+i.getFieldType()+"-item",this);a?(t=i.getFieldType(),e=!0):i=i.constructor.ancestor.prototype}else e=!0;while(!e);return t},setup:function(){var e=this;this.base();var i=e.resolveContainerTemplateType();if(!i)return t.throwErrorWithCallback("Unable to find template descriptor for container: "+e.getFieldType());this.containerDescriptor=this.view.getTemplateDescriptor("container-"+i,e);var a=!0;t.isEmpty(this.view.collapsible)||(a=this.view.collapsible),t.isEmpty(this.options.collapsible)||(a=this.options.collapsible),this.options.collapsible=a;var n="button";t.isEmpty(this.view.legendStyle)||(n=this.view.legendStyle),t.isEmpty(this.options.legendStyle)||(n=this.options.legendStyle),this.options.legendStyle=n,this.lazyLoading=!1,t.isEmpty(this.options.lazyLoading)||(this.lazyLoading=this.options.lazyLoading,this.lazyLoading&&(this.options.collapsed=!0)),this.children=[],this.childrenById={},this.childrenByPropertyId={}},destroy:function(){this.form&&(this.form.destroy(!0),delete this.form),t.each(this.children,function(){this.destroy()}),this.base()},renderFieldElements:function(i){var a=this;this.container=e(this.field).find("."+t.MARKER_CLASS_CONTAINER_FIELD),this.container.removeClass(t.MARKER_CLASS_CONTAINER_FIELD),a.prepareContainerModel(function(e){a.beforeRenderContainer(e,function(){a.renderContainer(e,function(n){n&&(a.container.replaceWith(n),a.container=n,a.container.addClass(t.CLASS_CONTAINER)),a.container.addClass(a.view.horizontal?"alpaca-horizontal":"alpaca-vertical"),a.fireCallback("container"),a.afterRenderContainer(e,function(){i()})})})})},prepareContainerModel:function(e){var t=this,i={id:this.getId(),name:this.name,schema:this.schema,options:this.options,view:this.view};t.createItems(function(t){t||(t=[]);for(var a=0;a0)){r={};for(var o=0;o0?(e(n.container).addClass("alpaca-container-has-items"),e(n.container).attr("data-alpaca-container-item-count",i.items.length)):(e(n.container).removeClass("alpaca-container-has-items"),e(n.container).removeAttr("data-alpaca-container-item-count"));for(var o=0;o0&&(e(l.containerItemEl).appendTo(p),l.domEl=p)}e(c).remove()}else{var p=e(c).parent();e(c).replaceWith(l.containerItemEl),l.domEl=p}e(l.containerItemEl).addClass("alpaca-container-item"),0===o&&e(l.containerItemEl).addClass("alpaca-container-item-first"),o+1===i.items.length&&e(l.containerItemEl).addClass("alpaca-container-item-last"),e(l.containerItemEl).attr("data-alpaca-container-item-index",o),e(l.containerItemEl).attr("data-alpaca-container-item-name",l.name),e(l.containerItemEl).attr("data-alpaca-container-item-parent-field-id",n.getId()),n.registerChild(l,o)}n.options.collapsible&&n.fireCallback("collapsible"),n.triggerUpdate(),a()},afterApplyCreatedItems:function(e,t){t()},registerChild:function(e,i){t.isEmpty(i)?this.children.push(e):this.children.splice(i,0,e),this.childrenById[e.getId()]=e,e.propertyId&&(this.childrenByPropertyId[e.propertyId]=e),e.parent=this},unregisterChild:function(e){var i=this.children[e];i&&(t.isEmpty(e)||this.children.splice(e,1),delete this.childrenById[i.getId()],i.propertyId&&delete this.childrenByPropertyId[i.propertyId],i.parent=null)},updateChildDOMElements:function(){var t=this,i=null;if(t.view.getLayout()&&(i=t.view.getLayout().bindings),!i){t.children.length>0?(e(t.getContainerEl()).addClass("alpaca-container-has-items"),e(t.getContainerEl()).attr("data-alpaca-container-item-count",t.children.length)):(e(t.getContainerEl()).removeClass("alpaca-container-has-items"),e(t.getContainerEl()).removeAttr("data-alpaca-container-item-count"));for(var a=0;a0&&(e=0),e>-1&&this.children[e].focus()},disable:function(){this.base();for(var e=0;ea;a+=1)indent+=" ";else"string"==typeof i&&(indent=i);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("JSON.stringify");return this.str("",{"":e})},i.prototype.quote=function(e){var t=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;return t.lastIndex=0,t.test(e)?'"'+e.replace(t,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'},i.prototype.str=function(e,t){var i,a,n,r,o,s=gap,l=t[e];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e)),"function"==typeof rep&&(l=rep.call(t,e,l)),typeof l){case"string":return this.quote(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(gap+=indent,o=[],"[object Array]"===Object.prototype.toString.apply(l)){for(r=l.length,i=0;r>i;i+=1)o[i]=this.str(i,l)||"null";return n=0===o.length?"[]":gap?"[\n"+gap+o.join(",\n"+gap)+"\n"+s+"]":"["+o.join(",")+"]",gap=s,n}if(rep&&"object"==typeof rep)for(r=rep.length,i=0;r>i;i+=1)a=rep[i],"string"==typeof a&&(n=this.str(a,l),n&&o.push(this.quote(a)+(gap?": ":":")+n));else for(a in l)Object.hasOwnProperty.call(l,a)&&(n=this.str(a,l),n&&o.push(this.quote(a)+(gap?": ":":")+n));return n=0===o.length?"{}":gap?"{\n"+gap+o.join(",\n"+gap)+"\n"+s+"}":"{"+o.join(",")+"}",gap=s,n}}}(jQuery),function(e){var t=e.alpaca;t.Form=Base.extend({constructor:function(e,i,a,n,r){if(this.domEl=e,this.parent=null,this.connector=n,this.errorCallback=r,this.options=i,this.attributes=this.options.attributes?this.options.attributes:{},this.options.buttons){this.options.buttons.submit&&(this.options.buttons.submit.type||(this.options.buttons.submit.type="submit"),this.options.buttons.submit.name||(this.options.buttons.submit.name="submit"),this.options.buttons.submit.value||(this.options.buttons.submit.value="Submit")),this.options.buttons.reset&&(this.options.buttons.reset.type||(this.options.buttons.reset.type="reset"),this.options.buttons.reset.name||(this.options.buttons.reset.name="reset"),this.options.buttons.reset.value||(this.options.buttons.reset.value="Reset")); -for(var o in this.options.buttons)this.options.buttons[o].label&&(this.options.buttons[o].value=this.options.buttons[o].label),this.options.buttons[o].title&&(this.options.buttons[o].value=this.options.buttons[o].title),this.options.buttons[o].type||(this.options.buttons[o].type="button")}this.attributes.id?this.id=this.attributes.id:(this.id=t.generateId(),this.attributes.id=this.id),this.options.buttons&&this.options.buttons.submit&&t.isUndefined(this.options.toggleSubmitValidState)&&(this.options.toggleSubmitValidState=!0),this.viewType=i.viewType,this.view=new t.RuntimeView(a,this)},render:function(e){var t=this;this.form&&this.form.remove(),this.processRender(this.domEl,function(){t.form.appendTo(t.container),t.form.addClass("alpaca-form"),t.fireCallback("form"),e(t)})},isFormValid:function(){this.topControl.validate(!0);var e=this.topControl.isValid(!0);return e},isValid:function(){return this.isFormValid()},validate:function(e){return this.topControl.validate(e)},enableSubmitButton:function(){if(e(".alpaca-form-button-submit").attrProp("disabled",!1),e.mobile)try{e(".alpaca-form-button-submit").button("refresh")}catch(t){}},disableSubmitButton:function(){if(e(".alpaca-form-button-submit").attrProp("disabled",!0),e.mobile)try{e(".alpaca-form-button-submit").button("refresh")}catch(t){}},adjustSubmitButtonState:function(){this.disableSubmitButton(),this.isFormValid()&&this.enableSubmitButton()},processRender:function(i,a){var n=this;if(this.formDescriptor=this.view.getTemplateDescriptor("form"),!this.formDescriptor)return t.throwErrorWithCallback("Could not find template descriptor: form");var r=t.tmpl(this.formDescriptor,{id:this.getId(),options:this.options,view:this.view});r.appendTo(i),this.form=r,this.formFieldsContainer=e(this.form).find("."+t.MARKER_CLASS_FORM_ITEMS_FIELD),this.formFieldsContainer.removeClass(t.MARKER_CLASS_FORM_ITEMS_FIELD),t.isEmpty(this.form.attr("id"))&&this.form.attr("id",this.getId()+"-form-outer"),t.isEmpty(this.form.attr("data-alpaca-form-id"))&&this.form.attr("data-alpaca-form-id",this.getId()),i.find("form").attr(this.attributes),this.buttons={},e(i).find(".alpaca-form-button").each(function(){e(this).click(function(){e(this).attr("button-pushed",!0)});var t=e(this).attr("data-key");if(t){var i=n.options.buttons[t];i&&i.click&&e(this).click(function(e,t){return function(i){i.preventDefault(),t.call(e,i)}}(n,i.click))}}),a()},getId:function(){return this.id},getType:function(){return this.type},getParent:function(){return this.parent},getValue:function(){return this.topControl.getValue()},setValue:function(e){this.topControl.setValue(e)},initEvents:function(){var t=this,i=e(this.domEl).find("form"),a=this.getValue();e(i).submit(a,function(e){return t.onSubmit(e,t)}),this.options.toggleSubmitValidState&&(e(t.topControl.getFieldEl()).bind("fieldupdate",function(){t.adjustSubmitButtonState()}),this.adjustSubmitButtonState())},getButtonEl:function(t){return e(this.domEl).find(".alpaca-form-button-"+t)},onSubmit:function(e,i){if(this.submitHandler){e.stopPropagation();var a=this.submitHandler(e,i);return t.isUndefined(a)&&(a=!1),a}},registerSubmitHandler:function(e){t.isFunction(e)&&(this.submitHandler=e)},refreshValidationState:function(e,t){this.topControl.refreshValidationState(e,t)},disable:function(){this.topControl.disable()},enable:function(){this.topControl.enable()},focus:function(){this.topControl.focus()},destroy:function(e){this.getFormEl().remove(),!e&&this.parent&&this.parent.destroy()},show:function(){this.getFormEl().css({display:""})},hide:function(){this.getFormEl().css({display:"none"})},clear:function(e){this.topControl.clear(e)},isEmpty:function(){return this.topControl.isEmpty()},fireCallback:function(e,t,i,a,n,r){this.view.fireCallback(this,e,t,i,a,n,r)},getFormEl:function(){return this.form},submit:function(){this.form.submit()},ajaxSubmit:function(){var t=this;return e.ajax({data:this.getValue(),url:t.options.attributes.action,type:t.options.attributes.method,dataType:"json"})}})}(jQuery),function(e){var t=e.alpaca;t.Fields.TextField=t.ControlField.extend({getFieldType:function(){return"text"},setup:function(){this.base(),this.inputType||(this.inputType="text"),this.options.inputType&&(this.inputType=this.options.inputType),this.options.data||(this.options.data={}),this.options.attributes||(this.options.attributes={}),"undefined"==typeof this.options.allowOptionalEmpty&&(this.options.allowOptionalEmpty=!0)},destroy:function(){this.base(),this.control&&this.control.typeahead&&this.options.typeahead&&e(this.control).typeahead("destroy")},postRender:function(e){var t=this;this.base(function(){t.control&&(t.applyMask(),t.applyTypeAhead(),t.updateMaxLengthIndicator()),e()})},applyMask:function(){var e=this;e.control.mask&&e.options.maskString&&e.control.mask(e.options.maskString)},applyTypeAhead:function(){var i=this;if(i.control.typeahead&&i.options.typeahead&&!t.isEmpty(i.options.typeahead)){var a=i.options.typeahead.config;a||(a={});var n=i.options.typeahead.datasets;n||(n={}),n.name||(n.name=i.getId());var r=i.options.typeahead.events;if(r||(r={}),"local"===n.type||"remote"===n.type||"prefetch"===n.type){var o={datumTokenizer:function(e){return Bloodhound.tokenizers.whitespace(e.value)},queryTokenizer:Bloodhound.tokenizers.whitespace};if("local"===n.type){var s=[];if("function"==typeof n.source)o.local=n.source;else{for(var l=0;l=0?n="You have "+o+" characters remaining":(n="Your message is too long by "+-1*o+" characters",a=!0);var s=e(i.field).find(".alpaca-field-text-max-length-indicator");0===s.length&&(s=e("

"),e(i.control).after(s)),e(s).html(n),e(s).removeClass("err"),a&&e(s).addClass("err")}},getValue:function(){var t=this,i=null;if(!this.isDisplayOnly()&&this.control&&this.control.length>0){if(i=this._getControlVal(!0),t.control.mask&&t.options.maskString){var a=e(this.control).data(e.mask.dataName);a&&(i=a(),i=t.ensureProperType(i))}}else i=this.base();return i},setValue:function(e){this.control&&this.control.length>0&&this.control.val(t.isEmpty(e)?"":e),this.base(e),this.updateMaxLengthIndicator()},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validatePattern();return i.invalidPattern={message:a?"":t.substituteTokens(this.view.getMessage("invalidPattern"),[this.schema.pattern]),status:a},a=this._validateMaxLength(),i.stringTooLong={message:a?"":t.substituteTokens(this.view.getMessage("stringTooLong"),[this.schema.maxLength]),status:a},a=this._validateMinLength(),i.stringTooShort={message:a?"":t.substituteTokens(this.view.getMessage("stringTooShort"),[this.schema.minLength]),status:a},e&&i.invalidPattern.status&&i.stringTooLong.status&&i.stringTooShort.status},_validatePattern:function(){if(this.schema.pattern){var e=this.getValue();if(""===e&&this.options.allowOptionalEmpty&&!this.isRequired())return!0;if(t.isEmpty(e)&&(e=""),!e.match(this.schema.pattern))return!1}return!0},_validateMinLength:function(){if(!t.isEmpty(this.schema.minLength)){var e=this.getValue();if(""===e&&this.options.allowOptionalEmpty&&!this.isRequired())return!0;if(t.isEmpty(e)&&(e=""),e.lengththis.schema.maxLength)return!1}return!0},focus:function(){if(this.control&&this.control.length>0){var t=e(this.control).get(0);try{var i=t.value?t.value.length:0;t.selectionStart=i,t.selectionEnd=i}catch(a){}t.focus()}},getType:function(){return"string"},onKeyDown:function(e){var i=this;if(8===e.keyCode){if(!t.isEmpty(i.schema.minLength)&&(i.options.constrainLengths||i.options.constrainMinLength)){var a=i.getValue()||"";a.length<=i.schema.minLength&&(e.preventDefault(),e.stopImmediatePropagation())}}else if(!t.isEmpty(i.schema.maxLength)&&(i.options.constrainLengths||i.options.constrainMaxLength)){var a=i.getValue()||"";a.length>=i.schema.maxLength&&(e.preventDefault(),e.stopImmediatePropagation())}},onKeyUp:function(){var e=this;e.updateMaxLengthIndicator()},getTitle:function(){return"Single-Line Text"},getDescription:function(){return"Text field for single-line text."},getSchemaOfSchema:function(){return t.merge(this.base(),{properties:{minLength:{title:"Minimal Length",description:"Minimal length of the property value.",type:"number"},maxLength:{title:"Maximum Length",description:"Maximum length of the property value.",type:"number"},pattern:{title:"Pattern",description:"Regular expression for the property value.",type:"string"}}})},getOptionsForSchema:function(){return t.merge(this.base(),{fields:{"default":{helper:"Field default value",type:"text"},minLength:{type:"integer"},maxLength:{type:"integer"},pattern:{type:"text"}}})},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{size:{title:"Field Size",description:"Field size.",type:"number","default":40},maskString:{title:"Mask Expression",description:"Expression for the field mask. Field masking will be enabled if not empty.",type:"string"},placeholder:{title:"Field Placeholder",description:"Field placeholder.",type:"string"},typeahead:{title:"Type Ahead",description:"Provides configuration for the $.typeahead plugin if it is available. For full configuration options, see: https://github.com/twitter/typeahead.js"},allowOptionalEmpty:{title:"Allow Optional Empty",description:"Allows this non-required field to validate when the value is empty"},inputType:{title:"HTML5 Input Type",description:"Allows for the override of the underlying HTML5 input type. If not specified, an assumed value is provided based on the kind of input control (i.e. 'text', 'date', 'email' and so forth)",type:"string"},data:{title:"Data attributes for the underlying DOM input control",description:"Allows you to specify a key/value map of data attributes that will be added as DOM attribuets for the underlying input control. The data attributes will be added as data-{name}='{value}'.",type:"object"}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{size:{type:"integer"},maskString:{helper:"a - an alpha character;9 - a numeric character;* - an alphanumeric character",type:"text"},typeahead:{type:"object"},allowOptionalEmpty:{type:"checkbox"},inputType:{type:"text"},data:{type:"object"}}})}}),t.registerMessages({invalidPattern:"This field should have pattern {0}",stringTooShort:"This field should contain at least {0} numbers or characters",stringTooLong:"This field should contain at most {0} numbers or characters"}),t.registerFieldClass("text",t.Fields.TextField),t.registerDefaultSchemaFieldMapping("string","text")}(jQuery),function(e){var t=e.alpaca;t.Fields.TextAreaField=t.Fields.TextField.extend({getFieldType:function(){return"textarea"},setup:function(){this.base(),this.options.rows||(this.options.rows=5),this.options.cols||(this.options.cols=40)},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateWordCount();return i.wordLimitExceeded={message:a?"":t.substituteTokens(this.view.getMessage("wordLimitExceeded"),[this.options.wordlimit]),status:a},e&&i.wordLimitExceeded.status},_validateWordCount:function(){if(this.options.wordlimit&&this.options.wordlimit>-1){var e=this.data;if(e){var t=e.split(" ").length;if(t>this.options.wordlimit)return!1}}return!0},getTitle:function(){return"Multi-Line Text"},getDescription:function(){return"Textarea field for multiple line text."},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{rows:{title:"Rows",description:"Number of rows",type:"number","default":5},cols:{title:"Columns",description:"Number of columns",type:"number","default":40},wordlimit:{title:"Word Limit",description:"Limits the number of words allowed in the text area.",type:"number","default":-1}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{rows:{type:"integer"},cols:{type:"integer"},wordlimit:{type:"integer"}}})}}),t.registerMessages({wordLimitExceeded:"The maximum word limit of {0} has been exceeded."}),t.registerFieldClass("textarea",t.Fields.TextAreaField)}(jQuery),function(e){var t=e.alpaca;t.Fields.CheckBoxField=t.ControlField.extend({getFieldType:function(){return"checkbox"},setup:function(){var i=this;i.base(),this.options.rightLabel||(this.options.rightLabel=""),"undefined"==typeof i.options.multiple&&("array"===i.schema.type?i.options.multiple=!0:"undefined"!=typeof i.schema["enum"]&&(i.options.multiple=!0)),i.checkboxOptions=[],i.options.multiple&&e.each(i.getEnum(),function(e,a){var n=a;i.options.optionLabels&&(t.isEmpty(i.options.optionLabels[e])?t.isEmpty(i.options.optionLabels[a])||(n=i.options.optionLabels[a]):n=i.options.optionLabels[e]),i.checkboxOptions.push({value:a,text:n})})},getEnum:function(){var e=[];return this.schema&&this.schema["enum"]&&(e=this.schema["enum"]),e},onClick:function(){this.refreshValidationState()},prepareControlModel:function(e){var t=this;this.base(function(i){i.checkboxOptions=t.checkboxOptions,e(i)})},postRender:function(t){var i=this;this.base(function(){if(i.data&&"undefined"!=typeof i.data&&i.setValue(i.data),e(i.getFieldEl()).find("input:checkbox").change(function(){i.triggerWithPropagation("change")}),i.options.multiple&&(e(i.getFieldEl()).find("input:checkbox").prop("checked",!1),i.data)){var a=i.data;if("string"==typeof i.data){a=i.data.split(",");for(var n=0;n0?t.checked(e(l[0])):!1}return a},setValue:function(i){var a=this,n=function(i){t.isString(i)&&(i="true"===i);var n=e(a.getFieldEl()).find("input");n.length>0&&t.checked(e(n[0]),i)},r=function(n){"string"==typeof n&&(n=n.split(","));for(var r=0;r0&&t.checked(e(s[0]),i)}},o=!1;a.options.multiple?"string"==typeof i?(r(i),o=!0):t.isArray(i)&&(r(i),o=!0):"boolean"==typeof i?(n(i),o=!0):"string"==typeof i&&(n(i),o=!0),!o&&i&&t.logError("CheckboxField cannot set value for schema.type="+a.schema.type+" and value="+i),this.base(i)},_validateEnum:function(){var e=this;if(!e.options.multiple)return!0;var i=e.getValue();return!e.isRequired()&&t.isValEmpty(i)?!0:("string"==typeof i&&(i=i.split(",")),t.anyEquality(i,e.schema["enum"]))},disable:function(){e(this.control).find("input").each(function(){e(this).disabled=!0})},enable:function(){e(this.control).find("input").each(function(){e(this).disabled=!1})},getType:function(){return"boolean"},getTitle:function(){return"Checkbox Field"},getDescription:function(){return"Checkbox Field for boolean (true/false), string ('true', 'false' or comma-delimited string of values) or data array."},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{rightLabel:{title:"Option Label",description:"Optional right-hand side label for single checkbox field.",type:"string"},multiple:{title:"Multiple",description:"Whether to render multiple checkboxes for multi-valued type (such as an array or a comma-delimited string)",type:"boolean"}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{rightLabel:{type:"text"},multiple:{type:"checkbox"}}})}}),t.registerFieldClass("checkbox",t.Fields.CheckBoxField),t.registerDefaultSchemaFieldMapping("boolean","checkbox")}(jQuery),function(e){var t=e.alpaca;t.Fields.FileField=t.Fields.TextField.extend({getFieldType:function(){return"file"},setValue:function(e){this.data=e,this.data=e,this.updateObservable(),this.triggerUpdate()},getValue:function(){return this.data},onChange:function(e){this.base(e),this.options.selectionHandler&&this.processSelectionHandler(e.target.files)},processSelectionHandler:function(e){if(e&&e.length>0&&"undefined"!=typeof FileReader){var t=[],i=0,a=new FileReader;a.onload=function(){var a=this;return function(n){var r=n.target.result;t.push(r),i++,i===e.length&&a.options.selectionHandler.call(a,e,t)}}.call(this);for(var n=0;n0&&(i.data=i.schema.enum[0])},prepareControlModel:function(e){var t=this;this.base(function(i){i.noneLabel="None","undefined"!=typeof t.options.noneLabel&&(i.noneLabel=t.options.noneLabel),i.hideNone=t.isRequired(),"undefined"!=typeof t.options.removeDefaultNone&&(i.hideNone=t.options.removeDefaultNone),e(i)})},getEnum:function(){return this.schema&&this.schema["enum"]?this.schema["enum"]:void 0},getValue:function(i){var a=this;return t.isArray(i)?e.each(i,function(t,n){e.each(a.selectOptions,function(e,a){a.value===n&&(i[t]=a.value)})}):e.each(this.selectOptions,function(e,t){t.value===i&&(i=t.value)}),i},beforeRenderControl:function(i,a){var n=this;this.base(i,function(){if(n.options.dataSource){n.selectOptions=[];var r=function(){n.schema.enum=[],n.options.optionLabels=[];for(var e=0;e0&&(n.data=n.selectOptions[0].value,0===e("input:radio:checked",n.control).length&&t.checked(e(n.control).find('input:radio[value="'+n.data+'"]'),"checked")),n.options.vertical?e(n.control).css("display","block"):e(n.control).css("display","inline-block"),a()})},onClick:function(t){this.base(t);var i=this,a=e(t.currentTarget).find("input").val();"undefined"!=typeof a&&(i.setValue(a),i.refreshValidationState())},getTitle:function(){return"Radio Group Field"},getDescription:function(){return"Radio Group Field with list of options."},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{name:{title:"Field name",description:"Field name.",type:"string"},emptySelectFirst:{title:"Empty Select First",description:"If the data is empty, then automatically select the first item in the list.",type:"boolean","default":!1},vertical:{title:"Position the radio selector items vertically",description:"By default, radio controls are stacked vertically. Set to false if you'd like radio controls to lay out horizontally.",type:"boolean","default":!0}}})}}),t.registerFieldClass("radio",t.Fields.RadioField)}(jQuery),function(e){var t=e.alpaca;t.Fields.SelectField=t.Fields.ListField.extend({getFieldType:function(){return"select"},setup:function(){this.base()},getValue:function(){if(this.control&&this.control.length>0){var e=this._getControlVal(!0);return"undefined"==typeof e&&(e=this.data),this.base(e)}},setValue:function(e){t.isArray(e)?t.compareArrayContent(e,this.getValue())||(!t.isEmpty(e)&&this.control&&this.control.val(e),this.base(e)):e!==this.getValue()&&(this.control&&"undefined"!=typeof e&&null!=e&&this.control.val(e),this.base(e))},getEnum:function(){if(this.schema){if(this.schema["enum"])return this.schema["enum"];if(this.schema.type&&"array"===this.schema.type&&this.schema.items&&this.schema.items["enum"])return this.schema.items["enum"]}},initControlEvents:function(){var e=this;if(e.base(),e.options.multiple){var t=this.control.parent().find("button.multiselect");t.focus(function(t){e.suspendBlurFocus||(e.onFocus.call(e,t),e.trigger("focus",t))}),t.blur(function(t){e.suspendBlurFocus||(e.onBlur.call(e,t),e.trigger("blur",t))})}},beforeRenderControl:function(e,t){var i=this;this.base(e,function(){i.schema.type&&"array"===i.schema.type&&(i.options.multiple=!0),t()})},prepareControlModel:function(e){var t=this;this.base(function(i){i.selectOptions=t.selectOptions,e(i)})},afterRenderControl:function(i,a){var n=this;this.base(i,function(){if(t.isUndefined(n.data)&&n.options.emptySelectFirst&&n.selectOptions&&n.selectOptions.length>0&&(n.data=n.selectOptions[0].value),n.data&&n.setValue(n.data),n.options.multiple&&e.fn.multiselect){var i=null;i=n.options.multiselect?n.options.multiselect:{},i.nonSelectedText||(i.nonSelectedText="None",n.options.noneLabel&&(i.nonSelectedText=n.options.noneLabel)),n.options.hideNone&&delete i.nonSelectedText,e(n.getControlEl()).multiselect(i)}a()})},_validateEnum:function(){var i=this;if(this.schema["enum"]){var a=this.data;if(!this.isRequired()&&t.isValEmpty(a))return!0;if(this.options.multiple){var n=!0;return a||(a=[]),t.isArray(a)||t.isObject(a)||(a=[a]),e.each(a,function(t,a){return e.inArray(a,i.schema["enum"])<=-1?(n=!1,!1):void 0}),n}return e.inArray(a,this.schema["enum"])>-1}return!0},onChange:function(e){this.base(e);var i=this;t.later(25,this,function(){var e=i.getValue();i.setValue(e),i.refreshValidationState()})},_validateMinItems:function(){return this.schema.items&&this.schema.items.minItems&&e(":selected",this.control).lengththis.schema.items.maxItems?!1:!0},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateMaxItems();return i.tooManyItems={message:a?"":t.substituteTokens(this.view.getMessage("tooManyItems"),[this.schema.items.maxItems]),status:a},a=this._validateMinItems(),i.notEnoughItems={message:a?"":t.substituteTokens(this.view.getMessage("notEnoughItems"),[this.schema.items.minItems]),status:a},e&&i.tooManyItems.status&&i.notEnoughItems.status},getTitle:function(){return"Select Field"},getDescription:function(){return"Select Field"},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{multiple:{title:"Mulitple Selection",description:"Allow multiple selection if true.",type:"boolean","default":!1},size:{title:"Displayed Options",description:"Number of options to be shown.",type:"number"},emptySelectFirst:{title:"Empty Select First",description:"If the data is empty, then automatically select the first item in the list.",type:"boolean","default":!1},multiselect:{title:"Multiselect Plugin Settings",description:"Multiselect plugin properties - http://davidstutz.github.io/bootstrap-multiselect",type:"any"}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{multiple:{rightLabel:"Allow multiple selection ?",helper:"Allow multiple selection if checked",type:"checkbox"},size:{type:"integer"},emptySelectFirst:{type:"checkbox",rightLabel:"Empty Select First"},multiselect:{type:"object",rightLabel:"Multiselect plugin properties - http://davidstutz.github.io/bootstrap-multiselect"}}})}}),t.registerFieldClass("select",t.Fields.SelectField)}(jQuery),function(e){var t=e.alpaca;t.Fields.NumberField=t.Fields.TextField.extend({setup:function(){this.base()},getFieldType:function(){return"number"},getValue:function(){var e=this._getControlVal(!0);return"undefined"==typeof e||""==e?e:parseFloat(e)},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateNumber();return i.stringNotANumber={message:a?"":this.view.getMessage("stringNotANumber"),status:a},a=this._validateDivisibleBy(),i.stringDivisibleBy={message:a?"":t.substituteTokens(this.view.getMessage("stringDivisibleBy"),[this.schema.divisibleBy]),status:a},a=this._validateMaximum(),i.stringValueTooLarge={message:"",status:a},a||(i.stringValueTooLarge.message=this.schema.exclusiveMaximum?t.substituteTokens(this.view.getMessage("stringValueTooLargeExclusive"),[this.schema.maximum]):t.substituteTokens(this.view.getMessage("stringValueTooLarge"),[this.schema.maximum])),a=this._validateMinimum(),i.stringValueTooSmall={message:"",status:a},a||(i.stringValueTooSmall.message=this.schema.exclusiveMinimum?t.substituteTokens(this.view.getMessage("stringValueTooSmallExclusive"),[this.schema.minimum]):t.substituteTokens(this.view.getMessage("stringValueTooSmall"),[this.schema.minimum])),a=this._validateMultipleOf(),i.stringValueNotMultipleOf={message:"",status:a},a||(i.stringValueNotMultipleOf.message=t.substituteTokens(this.view.getMessage("stringValueNotMultipleOf"),[this.schema.multipleOf])),e&&i.stringNotANumber.status&&i.stringDivisibleBy.status&&i.stringValueTooLarge.status&&i.stringValueTooSmall.status&&i.stringValueNotMultipleOf.status},_validateNumber:function(){var e=this._getControlVal();if("number"==typeof e&&(e=""+e),t.isValEmpty(e))return!0;var i=t.testRegex(t.regexps.number,e);if(!i)return!1;var a=this.getValue();return isNaN(a)?!1:!0},_validateDivisibleBy:function(){var e=this.getValue();return t.isEmpty(this.schema.divisibleBy)||e%this.schema.divisibleBy===0?!0:!1},_validateMaximum:function(){var e=this.getValue();if(!t.isEmpty(this.schema.maximum)){if(e>this.schema.maximum)return!1;if(!t.isEmpty(this.schema.exclusiveMaximum)&&e==this.schema.maximum&&this.schema.exclusiveMaximum)return!1}return!0},_validateMinimum:function(){var e=this.getValue();if(!t.isEmpty(this.schema.minimum)){if(ea?(n.setValue(e[a]),a++):i.removeItem(a)}while(a");l.alpaca({data:r,options:n,schema:a,view:this.view.id?this.view.id:this.view,connector:this.connector,error:function(e){s.destroy(),s.errorCallback.call(s,e)},notTopLevel:!0,render:function(e,t){e.parent=s,e.path=s.path+"["+i+"]",e.render(null,function(){s.refreshValidationState(),s.updatePathAndName(),s.triggerUpdate(),t&&t()})},postRender:function(i){var a=t.tmpl(s.containerItemTemplateDescriptor,{id:s.getId(),name:i.name,parentFieldId:s.getId(),actionbarStyle:s.options.actionbarStyle,view:s.view,data:r}),n=e(a).find("."+t.MARKER_CLASS_CONTAINER_FIELD_ITEM_FIELD);return 0===n.length&&e(a).hasClass(t.MARKER_CLASS_CONTAINER_FIELD_ITEM_FIELD)&&(n=e(a)),0===n.length?void s.errorCallback.call(s,{message:"Cannot find insertion point for field: "+s.getId()}):(e(n).before(i.getFieldEl()),e(n).remove(),i.containerItemEl=a,t.isFunction(s.options.items.postRender)&&s.options.items.postRender.call(i,n),void(o&&o(i)))}})}},resolveItemSchemaOptions:function(e){var i,a=this,n=function(t,i,n){a.options.readonly&&(i.readonly=!0),e(t,i,n)};!i&&a.options&&a.options.fields&&a.options.fields.item&&(i=a.options.fields.item),!i&&a.options&&a.options.items&&(i=a.options.items);var r;if(a.schema&&a.schema.items&&(r=a.schema.items),r&&r.$ref){for(var o=r.$ref,s=this,l=[s];s.parent;)s=s.parent,l.push(s);var c=r,d=i;t.loadRefSchemaOptions(s,o,function(e,i){for(var a=0,r=0;r1,p={};c&&t.mergeObject(p,c),e&&t.mergeObject(p,e),delete p.id;var u={};d&&t.mergeObject(u,d),i&&t.mergeObject(u,i),t.nextTick(function(){n(p,u,s)})})}else t.nextTick(function(){n(r,i)})},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateUniqueItems();return i.valueNotUnique={message:a?"":this.view.getMessage("valueNotUnique"),status:a},a=this._validateMaxItems(),i.tooManyItems={message:a?"":t.substituteTokens(this.view.getMessage("tooManyItems"),[this.schema.items.maxItems]),status:a},a=this._validateMinItems(),i.notEnoughItems={message:a?"":t.substituteTokens(this.view.getMessage("notEnoughItems"),[this.schema.items.minItems]),status:a},e&&i.valueNotUnique.status&&i.tooManyItems.status&&i.notEnoughItems.status},_validateEqualMaxItems:function(){return this.schema.items&&this.schema.items.maxItems&&this.getSize()>=this.schema.items.maxItems?!1:!0},_validateEqualMinItems:function(){return this.schema.items&&this.schema.items.minItems&&this.getSize()<=this.schema.items.minItems?!1:!0},_validateMinItems:function(){return this.schema.items&&this.schema.items.minItems&&this.getSize()this.schema.items.maxItems?!1:!0},_validateUniqueItems:function(){if(this.schema.items&&this.schema.uniqueItems)for(var e={},t=0,i=this.children.length;i>t;++t){if(e.hasOwnProperty(this.children[t]))return!1;e[this.children[t]]=!0}return!0},findAction:function(t,i){var a=null;return e.each(t,function(e,t){t.action==i&&(a=t)}),a},postRender:function(e){var t=this;this.base(function(){t.updateToolbars(),e()})},getSize:function(){return this.children.length},updatePathAndName:function(){var i=function(a){a.children&&e.each(a.children,function(n,r){a.prePath&&t.startsWith(r.path,a.prePath)&&(r.prePath=r.path,r.path=r.path.replace(a.prePath,a.path)),a.preName&&t.startsWith(r.name,a.preName)&&(r.preName=r.name,r.name=r.name.replace(a.preName,a.name),r.field&&e(r.field).attr("name",r.name)),i(r)})};this.children&&this.children.length>0&&e.each(this.children,function(t,a){var n=a.path.lastIndexOf("/"),r=a.path.substring(n+1);r.indexOf("[")<0&&r.indexOf("]")<0&&(r=r.substring(r.indexOf("[")+1,r.indexOf("]"))),r!==t&&(a.prePath=a.path,a.path=a.path.substring(0,n)+"/["+t+"]"),a.nameCalculated&&(a.preName=a.name,a.parent&&a.parent.name&&a.path?a.name=a.parent.name+"_"+t:a.path&&(a.name=a.path.replace(/\//g,"").replace(/\[/g,"_").replace(/\]/g,"")),this.parent.options.rubyrails?e(a.field).attr("name",a.parent.name):e(a.field).attr("name",a.name)),a.prePath||(a.prePath=a.path),i(a)})},updateToolbars:function(){var t=this;if("display"!==this.view.type&&!this.schema.readonly){t.toolbar&&(t.fireCallback("arrayToolbar",!0),t.fireCallback("arrayToolbar")),t.actionbar&&(t.fireCallback("arrayActionbars",!0),t.fireCallback("arrayActionbars"));var i=e(this.getFieldEl()).find(".alpaca-array-toolbar[data-alpaca-array-toolbar-field-id='"+t.getId()+"']");if(this.children.length>0?e(i).hide():(e(i).show(),e(i).find("[data-alpaca-array-toolbar-action]").each(function(){var i=e(this).attr("data-alpaca-array-toolbar-action"),a=t.findAction(t.toolbar.actions,i);a&&e(this).off().click(function(e){e.preventDefault(),a.click.call(t,i,a)})})),this.options.toolbarSticky)e(t.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-field-id='"+t.getId()+"']").show();else{var a=this.getFieldEl().find(".alpaca-container-item");e(a).each(function(i){var a=e(t.containerItemEl).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-field-id='"+t.getId()+"'][data-alpaca-array-actionbar-item-index='"+i+"']");a&&a.length>0&&(e(this).hover(function(){e(a).show()},function(){e(a).hide()}),e(a).hide())})}var n=e(this.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-parent-field-id='"+t.getId()+"']");e(n).each(function(){var i=e(this).attr("data-alpaca-array-actionbar-item-index");"string"==typeof i&&(i=parseInt(i,10)),e(this).find("[data-alpaca-array-actionbar-action]").each(function(){var a=e(this).attr("data-alpaca-array-actionbar-action"),n=t.findAction(t.actionbar.actions,a);n&&e(this).off().click(function(e){e.preventDefault(),n.click.call(t,a,n,i)})}),e(this).find("[data-alpaca-array-actionbar-action='add']").each(t._validateEqualMaxItems()?function(){e(this).removeClass("alpaca-button-disabled"),t.fireCallback("enableButton",this)}:function(){e(this).addClass("alpaca-button-disabled"),t.fireCallback("disableButton",this)}),e(this).find("[data-alpaca-array-actionbar-action='remove']").each(t._validateEqualMinItems()?function(){e(this).removeClass("alpaca-button-disabled"),t.fireCallback("enableButton",this)}:function(){e(this).addClass("alpaca-button-disabled"),t.fireCallback("disableButton",this)})}),e(n).first().find("[data-alpaca-array-actionbar-action='up']").each(function(){e(this).addClass("alpaca-button-disabled"),t.fireCallback("disableButton",this)}),e(n).last().find("[data-alpaca-array-actionbar-action='down']").each(function(){e(this).addClass("alpaca-button-disabled"),t.fireCallback("disableButton",this)})}},doResolveItemContainer:function(){var t=this;return e(t.container)},doAddItem:function(t,i){var a=this,n=a.doResolveItemContainer();if(0===t)e(n).append(i.containerItemEl);else{var r=n.children("[data-alpaca-container-item-index='"+(t-1)+"']");r&&r.length>0&&r.after(i.containerItemEl)}a.doAfterAddItem(i)},doAfterAddItem:function(){},addItem:function(e,t,i,a,n){var r=this;r._validateEqualMaxItems()&&r.createItem(e,t,i,a,function(t){r.registerChild(t,e),r.doAddItem(e,t),r.updateChildDOMElements(),r.updateToolbars(),r.refreshValidationState(),r.triggerUpdate(),n&&n()})},doRemoveItem:function(e){var t=this,i=t.doResolveItemContainer();i.children(".alpaca-container-item[data-alpaca-container-item-index='"+e+"']").remove()},removeItem:function(e,t){var i=this;this._validateEqualMinItems()&&(i.unregisterChild(e),i.doRemoveItem(e),i.updateChildDOMElements(),i.updateToolbars(),i.refreshValidationState(),i.triggerUpdate(),t&&t())},moveItem:function(i,a,n,r){var o=this;if("function"==typeof n&&(r=n,n=o.options.animate),"undefined"==typeof n&&(n=o.options.animate?o.options.animate:!0),"string"==typeof i&&(i=parseInt(i,10)),"string"==typeof a&&(a=parseInt(a,10)),0>a&&(a=0),a>=o.children.length&&(a=o.children.length-1),-1!==a&&i!==a){var s=o.children[a];if(s){var l=o.getId(),c=o.getContainerEl().find(".alpaca-container-item[data-alpaca-container-item-index='"+i+"'][data-alpaca-container-item-parent-field-id='"+l+"']"),d=o.getContainerEl().find(".alpaca-container-item[data-alpaca-container-item-index='"+a+"'][data-alpaca-container-item-parent-field-id='"+l+"']"),p=e("
");c.before(p);var u=e("
");d.before(u);var h=function(){for(var t=[],n=0;n0&&t.logDebug("There were "+i.length+" extra data keys that were not part of the schema "+JSON.stringify(i)),e(a)},l=[];for(var c in o){var d=null;i.data&&(d=i.data[c]);var p=function(e,n,r){return function(o){i.resolvePropertySchemaOptions(e,function(s,l,c){return c?t.throwErrorWithCallback("Circular reference detected for schema: "+s,i.errorCallback):(s||t.logDebug("Unable to resolve schema for property: "+e),void i.createItem(e,s,l,n,null,function(i){a.push(i),delete r[e],t.nextTick(function(){o()})}))})}}(c,d,n);l.push(p)}t.series(l,function(){s()})},createItem:function(i,a,n,r,o,s){var l=this,c=e("
");c.alpaca({data:r,options:n,schema:a,view:this.view.id?this.view.id:this.view,connector:this.connector,error:function(e){l.destroy(),l.errorCallback.call(_this,e)},notTopLevel:!0,render:function(e,t){e.parent=l,e.propertyId=i,e.path="/"!==l.path?l.path+"/"+i:l.path+i,e.render(null,function(){t()})},postRender:function(i){var a=t.tmpl(l.containerItemTemplateDescriptor,{id:l.getId(),name:i.name,parentFieldId:l.getId(),actionbarStyle:l.options.actionbarStyle,view:l.view,data:r}),n=e(a).find("."+t.MARKER_CLASS_CONTAINER_FIELD_ITEM_FIELD);return 0===n.length&&e(a).hasClass(t.MARKER_CLASS_CONTAINER_FIELD_ITEM_FIELD)&&(n=e(a)),0===n.length?void l.errorCallback.call(l,{message:"Cannot find insertion point for field: "+l.getId()}):(e(n).before(i.getFieldEl()),e(n).remove(),i.containerItemEl=a,void(s&&s(i)))}})},resolvePropertySchemaOptions:function(e,i){var a=this,n=function(e,t,n){a.options.readonly&&(t.readonly=!0),i(e,t,n)},r=null;a.schema&&a.schema.properties&&a.schema.properties[e]&&(r=a.schema.properties[e]);var o={};if(a.options&&a.options.fields&&a.options.fields[e]&&(o=a.options.fields[e]),r&&r.$ref){for(var s=r.$ref,l=this,c=[l];l.parent;)l=l.parent,c.push(l);var d=r,p=o;t.loadRefSchemaOptions(l,s,function(e,i){for(var a=0,r=0;r1,l={};d&&t.mergeObject(l,d),e&&t.mergeObject(l,e),d&&d.id&&(l.id=d.id);var u={};p&&t.mergeObject(u,p),i&&t.mergeObject(u,i),t.nextTick(function(){n(l,u,o)})})}else t.nextTick(function(){n(r,o)})},applyCreatedItems:function(e,t){var i=this;this.base(e,function(){var a=function(n){if(n===e.items.length)return void t();var r=e.items[n],o=r.propertyId;i.showOrHidePropertyBasedOnDependencies(o),i.bindDependencyFieldUpdateEvent(o),i.refreshDependentFieldStates(o),a(n+1)};a(0)})},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateMaxProperties();return i.tooManyProperties={message:a?"":t.substituteTokens(this.view.getMessage("tooManyProperties"),[this.schema.maxProperties]),status:a},a=this._validateMinProperties(),i.tooFewProperties={message:a?"":t.substituteTokens(this.view.getMessage("tooManyItems"),[this.schema.items.minProperties]),status:a},e&&i.tooManyProperties.status&&i.tooFewProperties.status},_validateMaxProperties:function(){if("undefined"==typeof this.schema.maxProperties)return!0;var e=this.schema.maxProperties,t=0;for(var i in this.data)t++;return e>=t},_validateMinProperties:function(){if("undefined"==typeof this.schema.minProperties)return!0;var e=this.schema.minProperties,t=0;for(var i in this.data)t++;return t>=e},showOrHidePropertyBasedOnDependencies:function(e){var i=this,a=this.childrenByPropertyId[e];if(!a)return t.throwErrorWithCallback("Missing property: "+e,i.errorCallback);var n=this.determineAllDependenciesValid(e);n?(a.show(),a.onDependentReveal()):(a.hide(),a.onDependentConceal()),a.getFieldEl().trigger("fieldupdate")},determineAllDependenciesValid:function(i){var a=this,n=this.childrenByPropertyId[i];if(!n)return t.throwErrorWithCallback("Missing property: "+i,a.errorCallback);var r=n.schema.dependencies;if(!r)return!0;var o=!0;return t.isString(r)?o=a.determineSingleDependencyValid(i,r):t.isArray(r)&&e.each(r,function(e,t){o=o&&a.determineSingleDependencyValid(i,t)}),o},bindDependencyFieldUpdateEvent:function(i){var a=this,n=this.childrenByPropertyId[i];if(!n)return t.throwErrorWithCallback("Missing property: "+i,a.errorCallback);var r=n.schema.dependencies;if(!r)return!0;var o=function(e,i){var r=t.resolveField(a,i);r&&(r.getFieldEl().bind("fieldupdate",function(e,t,i){return function(){a.showOrHidePropertyBasedOnDependencies(i),e.getFieldEl().trigger("fieldupdate")}}(n,r,e,i)),r.getFieldEl().trigger("fieldupdate"))};t.isString(r)?o(i,r):t.isArray(r)&&e.each(r,function(e,t){o(i,t)})},refreshDependentFieldStates:function(i){var a=this,n=this.childrenByPropertyId[i];if(!n)return t.throwErrorWithCallback("Missing property: "+i,a.errorCallback);var r=n.schema.dependencies;if(!r)return!0;var o=function(e){var i=t.resolveField(a,e);i&&i.getFieldEl().trigger("fieldupdate")};t.isString(r)?o(r):t.isArray(r)&&e.each(r,function(e,t){o(t)})},determineSingleDependencyValid:function(e,i){var a=this,n=t.resolveField(a,i);if(!n)return!1;var r=n.data,o=!1,s=this.childrenByPropertyId[e].options.dependencies;if(s&&0!==s.length){"boolean"!==n.getType()||r||(r=!1);var l=s[i];!t.isEmpty(l)&&t.isFunction(l)?o=l.call(this,r):(o=!0,t.isArray(l)?t.anyEquality(r,l)&&(o=!1):t.isEmpty(l)||t.anyEquality(l,r)||(o=!1))}else o="boolean"!==n.getType()||this.childrenByPropertyId[e].options.dependencies||r?!t.isValEmpty(n.data):!1;return n&&n.isHidden()&&(o=!1),o},getIndex:function(e){if(t.isEmpty(e))return-1;for(var i=0;i0&&n.after(t.getFieldEl())}else e(s.container).append(t.getFieldEl());s.updateChildDOMElements(),s.refreshValidationState(!0,function(){s.triggerUpdate(),o&&o()})})},removeItem:function(t,i){var a=this;this.children=e.grep(this.children,function(e){return e.getId()!=t});var n=this.childrenById[t];delete this.childrenById[t],n.propertyId&&delete this.childrenByPropertyId[n.propertyId],n.destroy(),this.refreshValidationState(!0,function(){a.triggerUpdate(),i&&i()})},wizard:function(){var i=this,a=this.wizardConfigs.steps;a||(a=[]);var n=this.wizardConfigs.title,r=this.wizardConfigs.description,o=this.wizardConfigs.buttons;o||(o={}),o.previous||(o.previous={}),o.previous.title||(o.previous.title="Previous"),o.previous.align||(o.previous.align="left"),o.previous.type||(o.previous.type="button"),o.next||(o.next={}),o.next.title||(o.next.title="Next"),o.next.align||(o.next.align="right"),o.next.type||(o.next.type="button"),this.wizardConfigs.hideSubmitButton||(o.submit||(o.submit={}),o.submit.title||(o.submit.title="Submit"),o.submit.align||(o.submit.align="right"),o.submit.type||(o.submit.type="button"));for(var s in o)o[s].type||(o[s].type="button");var l=this.wizardConfigs.showSteps;"undefined"==typeof l&&(l=!0);var c=this.wizardConfigs.showProgressBar,d=this.wizardConfigs.validation;"undefined"==typeof d&&(d=!0);var n=e(this.field).attr("data-alpaca-wizard-title"),r=e(this.field).attr("data-alpaca-wizard-description"),p=e(this.field).attr("data-alpaca-wizard-validation");"undefined"!=typeof p&&(d=p?!0:!1);var u=e(this.field).attr("data-alpaca-wizard-show-steps");"undefined"!=typeof u&&(l=u?!0:!1);var h=e(this.field).attr("data-alpaca-wizard-show-progress-bar");"undefined"!=typeof h&&(c=h?!0:!1);var f=e(this.field).find("[data-alpaca-wizard-role='step']");0==a.length&&f.each(function(t){var i={},n=e(this).attr("data-alpaca-wizard-step-title");"undefined"!=typeof n&&(i.title=n),i.title||(i.title="Step "+t);var r=e(this).attr("data-alpaca-wizard-step-description");"undefined"!=typeof r&&(i.description=r),i.description||(i.description="Step "+t),a.push(i)}),"undefined"==typeof c&&a.length>1&&(c=!0);var m={};m.wizardTitle=n,m.wizardDescription=r,m.showSteps=l,m.performValidation=d,m.steps=a,m.buttons=o,m.schema=i.schema,m.options=i.options,m.data=i.data,m.showProgressBar=c,m.markAllStepsVisited=this.wizardConfigs.markAllStepsVisited,m.view=i.view;var g=i.view.getTemplateDescriptor("wizard",i);if(g){var v=t.tmpl(g,m);e(i.field).append(v);var b=e(v).find(".alpaca-wizard-nav"),y=e(v).find(".alpaca-wizard-steps"),w=e(v).find(".alpaca-wizard-buttons"),F=e(v).find(".alpaca-wizard-progress-bar");e(y).append(f),function(a,n,r,o){var s=0,l=e(r).find("[data-alpaca-wizard-button-key='previous']"),c=e(r).find("[data-alpaca-wizard-button-key='next']"),d=e(r).find("[data-alpaca-wizard-button-key='submit']"),p=function(){if(o.showSteps){if(o.visits||(o.visits={}),o.markAllStepsVisited)for(var t=e(a).find("[data-alpaca-wizard-step-index]"),i=0;ii?e(a).find("[data-alpaca-wizard-step-index='"+i+"']").addClass("completed"):i===s?e(a).find("[data-alpaca-wizard-step-index='"+i+"']").addClass("active"):o.visits&&o.visits[i]||e(a).find("[data-alpaca-wizard-step-index='"+i+"']").addClass("disabled"),o.visits&&o.visits[i]&&e(a).find("[data-alpaca-wizard-step-index='"+i+"']").addClass("visited")}if(o.showProgressBar){var r=s+1,p=o.steps.length+1,u=parseInt(r/p*100,10)+"%";e(F).find(".progress-bar").attr("aria-valuemax",p),e(F).find(".progress-bar").attr("aria-valuenow",r),e(F).find(".progress-bar").css("width",u)}l.hide(),c.hide(),d.hide(),1==o.steps.length?d.show():o.steps.length>1&&(s>0&&l.show(),c.show(),0==s?c.show():s==o.steps.length-1&&(c.hide(),d.show())),e(n).find("[data-alpaca-wizard-role='step']").hide(),e(e(n).find("[data-alpaca-wizard-role='step']")[s]).show()},u=function(a,r){if(!o.performValidation)return void r(!0);var l=[],c=e(e(n).find("[data-alpaca-wizard-role='step']")[s]);e(c).find(".alpaca-field").each(function(){var t=e(this).attr("data-alpaca-field-id");if(t){var a=i.childrenById[t];a&&l.push(a)}});for(var d=[],p=0;p=1){var t=o.buttons.previous;t&&t.click&&t.click.call(i,e),s--,p()}}),e(c).click(function(e){e.preventDefault(),s+1<=o.steps.length-1&&u("next",function(t){if(t){var a=o.buttons.next;a&&a.click&&a.click.call(i,e),s++,p()}})}),e(d).click(function(e){e.preventDefault(),s===o.steps.length-1&&u("submit",function(t){if(t){var a=o.buttons.submit;a&&(a.click?a.click.call(i,e):i.form&&i.form.submit())}})}),e(r).find("[data-alpaca-wizard-button-key]").each(function(){var t=e(this).attr("data-alpaca-wizard-button-key");if("submit"!=t&&"next"!=t&&"previous"!=t){var a=o.buttons[t];a&&a.click&&e(this).click(function(e){return function(t){e.click.call(i,t)}}(a))}}),e(a).find("[data-alpaca-wizard-step-index]").click(function(t){t.preventDefault();var i=e(this).attr("data-alpaca-wizard-step-index");i&&(i=parseInt(i,10),(i==s||o.visits&&o.visits[i])&&(s>i?(s=i,p()):i>s&&u(null,function(e){e&&(s=i,p()) -})))}),i.on("moveToStep",function(e){var t=e.index,i=e.skipValidation;"undefined"!=typeof t&&t<=o.steps.length-1&&(i?(s=t,p()):u(null,function(e){e&&(s=t,p())}))}),i.on("advanceOrSubmit",function(){u(null,function(t){t&&(s===o.steps.length-1?e(d).click():e(c).click())})}),p()}(b,y,w,m)}},autoWizard:function(){var t=this.wizardConfigs.bindings;t||(t={});for(var i in this.childrenByPropertyId)t.hasOwnProperty(i)||(t[i]=1);var a=!0;e(this.field).find("[data-alpaca-wizard-role='step']").length>0&&(a=!1);var n=1,r=[];do{r=[];for(var i in t)t[i]==n&&this.childrenByPropertyId&&this.childrenByPropertyId[i]&&r.push(this.childrenByPropertyId[i].field);if(r.length>0){var o=null;a?(o=e('
'),e(this.field).append(o)):o=e(e(this.field).find("[data-alpaca-wizard-role='step']")[n-1]);for(var s=0;s0);this.wizard()},getType:function(){return"object"},moveItem:function(i,a,n,r){var o=this;if("function"==typeof n&&(r=n,n=o.options.animate),"undefined"==typeof n&&(n=o.options.animate?o.options.animate:!0),"string"==typeof i&&(i=parseInt(i,10)),"string"==typeof a&&(a=parseInt(a,10)),0>a&&(a=0),a>=o.children.length&&(a=o.children.length-1),-1!==a){var s=o.children[a];if(s){var l=o.getContainerEl().children("[data-alpaca-container-item-index='"+i+"']"),c=o.getContainerEl().children("[data-alpaca-container-item-index='"+a+"']"),d=e("
");l.before(d);var p=e("
");c.before(p);var u=function(){for(var t=[],n=0;n