public static DesignerViewPage BuildPage(StackAppContext appContext, RequestQueryString requestQuery) { var layoutModel = EntityMetaData.Get(EntityCode.EntityLayout).GetSingle(appContext, requestQuery.ItemId); var entity = EntityMetaData.Get(requestQuery.RelatedEntityId); var view = TView.ParseFromJSON(layoutModel.GetValue("layoutjson", "")); if (view == null) { view = entity.GetDefaultLayoutView(0); } var pallet = BuildPallet(appContext, entity); var page = new DesignerViewPage(pallet, view); page.LayoutFields = view.Fields; page.Actions = new InvariantDictionary <Model.Form.ActionInfo>(); var saveAction = new ActionInfo("Studio/SaveDesigner", requestQuery, "BTN_SAVE") { Title = "Save", ActionType = ActionType.Save, ExecutionType = ActionExecutionType.Custom }; page.Actions.Add("BTN_SAVE", saveAction); return(page); }
public static List <ViewPageDataOnly> GetData(StackAppContext appContext, RequestQueryString requestQuery) { var baseEntity = EntityMetaData.Get(requestQuery.EntityId); var baseField = baseEntity.GetFieldSchema(requestQuery.FieldName); var childEntity = EntityMetaData.Get(baseField.RefObject); var ids = FetchDataModel(appContext, requestQuery.ItemId, baseField, childEntity); var pages = new List <ViewPageDataOnly>(); var lConext = new LayoutContext(appContext, 0, baseField.RefObject); lConext.Build(); foreach (var id in ids) { var query = new RequestQueryString() { EntityId = baseField.RefObject, ItemId = id }; var context = new EditFormContext(appContext, baseField.RefObject, query); context.Build(); context.CreateDataModel(); context.LayoutContext = lConext; var renderer = new EditFormRenderer(context); renderer.Generate(lConext); pages.Add(renderer.GetViewPageOnlyData()); } return(pages); }