public async Task <HttpResponseMessage> Index(string id, string app)
        {
            IPageViewDefinition siteDefinition;
            var found         = ResolveForApp <TerrificViewDefinitionRepository>(app).TryGetFromViewId(id, out siteDefinition);
            var appViewEngine = ResolveForApp <IViewEngine>(app);
            var tplInfo       = await ResolveForApp <ITemplateRepository>(app).GetTemplateAsync(siteDefinition.Template).ConfigureAwait(false);

            var data = new PageEditModel
            {
                PageJson = found ? JsonConvert.SerializeObject(siteDefinition, Formatting.Indented) : null,
                PageHtml = await CreateSiteHtml(await appViewEngine.CreateViewAsync(tplInfo).ConfigureAwait(false), siteDefinition).ConfigureAwait(false),
                Modules  = CreateModules(app),
                Layouts  = CreateLayouts(app),
                App      = app,
                Id       = id
            };

            var viewDefinition = DefaultLayout.WithDefaultLayout(new PartialViewDefinition
            {
                Template = "components/modules/PageEditor/PageEditor",
                Data     = data
            });

            viewDefinition.IncludeScript("assets/pageEditor.js");
            viewDefinition.IncludeStyle("assets/pageEditor.css");
            viewDefinition.IncludeStyle("/web/page_edit/bundle_app.css?app=" + app);

            return(await View(viewDefinition).ConfigureAwait(false));
        }
        public async Task <HttpResponseMessage> Index(string id, string app)
        {
            var moduleRepository = this.ResolveForApp <IModuleRepository>(app);
            var moduleDefinition = await moduleRepository.GetModuleDefinitionByIdAsync(id).ConfigureAwait(false);

            if (moduleDefinition == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            var modelProvider = this.ResolveForApp <IModelProvider>(app);

            var viewDefinition = DefaultLayout.WithDefaultLayout(new PartialViewDefinition
            {
                Template = "components/modules/ModuleDetail/ModuleDetail",
                Data     = GetOverviewModel(moduleDefinition, modelProvider.GetDataVariations(moduleDefinition), app)
            });

            viewDefinition.AddAction(new ActionModel
            {
                Name = "Add Data Variation",
                Link = string.Format("/web/module/createdata?id={0}&app={1}", id, app),
            });

            viewDefinition.AddAction(new ActionModel
            {
                Name = "Add Skin",
                Link = "#"
            });

            return(await View(viewDefinition).ConfigureAwait(false));
        }
Example #3
0
        public Task <HttpResponseMessage> Index()
        {
            var viewDefinition = DefaultLayout.WithDefaultLayout(new PartialViewDefinition <ApplicationOverviewModel>
            {
                Template = "components/modules/ApplicationOverview/ApplicationOverview",
                Data     = GetOverviewModel()
            });

            return(View(viewDefinition));
        }
        public Task <HttpResponseMessage> Index(string schema, string data, string app)
        {
            var model = GetModel(schema, data);

            model.TemplatePartials = string.Join(",", this.ResolveForApp <ITemplateRepository>(app).GetAll().Select(a => string.Concat("\"", a.Id, "\"")).ToArray());

            var viewDefinition = IncludeResources(DefaultLayout.WithDefaultLayout(GetDataEditor(model)));

            AddSaveAction(viewDefinition, model);

            return(View(viewDefinition));
        }
        public Task <HttpResponseMessage> IndexAdvanced()
        {
            var model          = GetModel(null, null);
            var viewDefinition = IncludeResources(DefaultLayout.WithDefaultLayout(new PartialViewDefinition
            {
                Template      = "components/modules/AdvancedEditor/AdvancedEditor",
                ExtensionData = new Dictionary <string, object>
                {
                    { "save_action_id", model.SaveActionId }
                },
                Placeholder = new PlaceholderDefinitionCollection
                {
                    { "rightPanel", new [] { GetDataEditor(model) } }
                }
            }));

            AddSaveAction(viewDefinition, model);

            return(View(viewDefinition));
        }