Exemple #1
0
        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);
        }
        public FilterWidgetResponse BuildWithData(CustomRequestInfo request, RequestQueryString requestQuery)
        {
            if (request != null && request.Value != null)
            {
                var filtersRes = new List <ViewPage>();
                var filterJson = request.Value;
                var exp        = FilterExpression.BuildFromJson(requestQuery.EntityId, filterJson.ToString());
                foreach (var field in exp.GetAll())
                {
                    var formContext = new EditFormContext(Context, EntityCode.User, requestQuery);
                    formContext.Build();

                    var fieldInfo = formContext.Entity.GetFieldSchema(field.FieldName);
                    CreateWidgets(formContext, fieldInfo, field);

                    var page = new ViewPage(formContext);
                    filtersRes.Add(page);
                }

                return(new FilterWidgetResponse()
                {
                    Filters = filtersRes
                });
            }

            return(null);
        }
        public FilterWidgetResponse Generate(CustomRequestInfo request, RequestQueryString requestQuery)
        {
            var formContext = new EditFormContext(Context, requestQuery.EntityId, requestQuery);

            formContext.Build();
            if (request != null && request.Value != null)
            {
                JObject fieldId   = (JObject)request.Value;
                var     fid       = fieldId["Value"];
                var     fieldInfo = formContext.Entity.GetFieldSchema(Convert.ToInt32(fid));
                if (fieldInfo == null)
                {
                    throw new EntityException("Invalid field!");
                }

                CreateWidgets(formContext, fieldInfo);
            }

            var page = new ViewPage(formContext);

            var filtersRes = new List <ViewPage>()
            {
                page
            };

            return(new FilterWidgetResponse()
            {
                Filters = filtersRes
            });
        }
Exemple #4
0
        public ViewPage GetPage()
        {
            var formContext = new EditFormContext(_appContext, EntityCode.User, new RequestQueryString());

            formContext.Build();

            AddField(formContext);

            return(this.View);
        }
        public IActionResult Edit()
        {
            var context = new EditFormContext(this.WebAppContext, this.RequestQuery.EntityId, this.RequestQuery);

            context.Build();

            var builder = new EntityPageBuilder();
            var page    = builder.CreateEditPage(context);

            return(CreatePageResult(page));
        }
        private ViewPage BuildRefForm(StackAppContext appContext, EntityCode refEntity)
        {
            var q = new RequestQueryString();

            q.EntityId = refEntity;
            var context = new EditFormContext(appContext, refEntity, q);

            context.Build();

            var builder = new PageBuilder.EntityPageBuilder();
            var page    = builder.CreateNewPage(context);

            return(page);
        }
        public SubmitActionResponse GetSaveAction(RequestQueryString requestQuery, UIFormModel model)
        {
            var context = new EditFormContext(_AppContext, requestQuery.EntityId, requestQuery);

            context.Build(model);

            var generator = new EntityModelGenerator(context);

            generator.Generate(model);

            var response = new SubmitActionResponse(null);

            response.Status = SubmitStatus.Fail;

            if (generator.Status == AnyStatus.Success)
            {
                var recordModel = generator.RecordModel;
                var saveStatus  = context.Entity.Save(_AppContext, recordModel);
                if (saveStatus == AnyStatus.Success)
                {
                    response.Status      = SubmitStatus.Success;
                    response.RedirectUrl = AppLinkProvider.GetDetailPageLink(recordModel.EntityId, recordModel.ID).Url;
                    return(response);
                }
                else if (saveStatus == AnyStatus.InvalidData)
                {
                    PrepareErrorModel(recordModel, ref model);
                    response.Model = model;
                    return(response);
                }
                response.Message = saveStatus.Message;
                return(response);
            }
            response.Message = generator.Status.Message;

            return(response);
        }