예제 #1
0
        public void PageInit()
        {
            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = "/sdk/objects/data_source/l/list";
            }

            DataSourceObject = dsMan.Get(RecordId ?? Guid.Empty);
            if (DataSourceObject == null)
            {
                return;
            }

            var returnUrlEncoded = HttpUtility.UrlEncode(PageUtils.GetCurrentUrl(PageContext.HttpContext));

            if (DataSourceObject is DatabaseDataSource)
            {
                var existingPageDataSources = new PageService().GetPageDataSourcesByDataSourceId(DataSourceObject.Id);
                if (existingPageDataSources.Count > 0)
                {
                    HeaderActions.Add($"<button type='button' class='btn btn-white btn-sm disabled' tooltip='There are existing page data sources related'><i class='fa fa-lock'></i> Delete Locked</button>");
                }
                else
                {
                    HeaderActions.Add($"<button type='submit' form='DeleteDataSourceForm' onclick='return confirm(\"Are you sure?\")' class='btn btn-white btn-sm'><i class='fa fa-trash-alt go-red'></i> Delete</button>");
                }

                HeaderActions.Add($"<a href='/sdk/objects/data_source/m/{RecordId}/manage?ReturnUrl={returnUrlEncoded}' class='btn btn-white btn-sm'><i class='fa fa-cog go-orange'></i> Manage</a>");
            }
            else
            {
                HeaderActions.Add($"<button type='button' class='btn btn-white btn-sm disabled'><i class='fa fa-lock'></i> Manage Locked</a>");
                HeaderActions.Add($"<button type='button' class='btn btn-white btn-sm disabled'><i class='fa fa-lock'></i> Delete Locked</button>");
            }
        }
예제 #2
0
        //public string SampleData
        //{
        //	get
        //	{
        //		var dbDS = DataSourceObject as DatabaseDataSource;
        //		if (dbDS != null)
        //		{
        //			try
        //			{
        //				List<EntityRecord> result = dsMan.Execute(dbDS.Id);
        //				if (result != null)
        //					return JsonConvert.SerializeObject(result, Formatting.Indented);
        //			}
        //			catch (EqlException eqlEx)
        //			{
        //				return eqlEx.Errors[0].Message;
        //			}
        //			catch (Exception ex)
        //			{
        //				return ex.Message;
        //			}
        //		}

        //		//TODO process code
        //		return string.Empty;
        //	}
        //}

        public void PageInit()
        {
            Init();

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = "/sdk/objects/data_source/l/list";
            }

            DataSourceObject = dsMan.Get(RecordId ?? Guid.Empty);
            if (DataSourceObject == null)
            {
                return;
            }

            var returnUrlEncoded = HttpUtility.UrlEncode(PageUtils.GetCurrentUrl(PageContext.HttpContext));

            if (DataSourceObject is DatabaseDataSource)
            {
                HeaderActions.Add($"<a href='/sdk/objects/data_source/m/{RecordId}/manage?ReturnUrl={returnUrlEncoded}' class='btn btn-white btn-sm'><i class='ti-settings go-orange'></i> Manage</a>");
            }
            else
            {
                HeaderActions.Add($"<button type='button' class='btn btn-white btn-sm disabled'><i class='ti-lock'></i> Locked</a>");
            }
        }
예제 #3
0
        public void PageInit()
        {
            Init();

            #region << Init Entity >>
            var entMan = new EntityManager();
            var relMan = new EntityRelationManager();

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;
            if (ErpEntity == null)
            {
                return;
            }

            var entityRelations = relMan.Read().Object.Where(x => x.TargetEntityId == ErpEntity.Id || x.OriginEntityId == ErpEntity.Id).ToList();
            Relation = entityRelations.SingleOrDefault(x => x.Id == RecordId);
            if (Relation == null)
            {
                return;
            }

            #endregion

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = $"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/l";
            }

            #region << Actions >>

            if (Relation.System)
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.Disabled, label: "Delete locked", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "fa fa-trash-alt", titleText: "System objects cannot be deleted"));
            }
            else
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.ConfirmAndSubmitForm, label: "Delete Relation", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "fa fa-trash-alt go-red"));
            };

            HeaderActions.Add($"<a href='/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/m/{RecordId}' class='btn btn-white btn-sm'><i class='fa fa-cog go-orange'></i> Manage Relation</a>");

            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "relations"));

            #endregion

            TypeOptions = ModelExtensions.GetEnumAsSelectOptions <EntityRelationType>().FindAll(x => x.Value != "1").ToList();
        }
예제 #4
0
        public void PageInit()
        {
            #region << Init App >>
            var appServ = new AppService();
            App = appServ.GetApplication(RecordId ?? Guid.Empty);
            #endregion

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = "/sdk/objects/application/l/list";
            }

            #region << Actions >>
            HeaderActions.Add($"<a href='/sdk/objects/page/c/create?returnUrl={HttpUtility.UrlEncode(CurrentUrl)}&Type=Application&AppId={(App != null ? App.Id.ToString() : "")}' class='btn btn-white btn-sm'><i class='fa fa-plus go-green'></i> CreatePage</a>");

            #endregion

            #region << Actions >>
            HeaderToolbar.AddRange(AdminPageUtils.GetAppAdminSubNav(App, "pages"));
            #endregion
        }
예제 #5
0
        public void PageInit()
        {
            Init();

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = "/sdk/objects/entity/l/list";
            }


            #region << Init Entity >>
            var entMan = new EntityManager();
            ErpEntity = entMan.ReadEntity(RecordId ?? Guid.Empty).Object;
            if (ErpEntity == null)
            {
                return;
            }

            if (ErpEntity.RecordScreenIdField != null)
            {
                var screenField = ErpEntity.Fields.FirstOrDefault(x => x.Id == ErpEntity.RecordScreenIdField);
                if (screenField != null)
                {
                    RecordScreenIdFieldName = screenField.Name;
                }
            }

            #endregion

            #region << Init RecordPermissions >>
            var valueGrid = new List <KeyStringList>();
            PermissionOptions = new List <SelectOption>()
            {
                new SelectOption("create", "create"),
                new SelectOption("read", "read"),
                new SelectOption("update", "update"),
                new SelectOption("delete", "delete")
            };

            var roles = AdminPageUtils.GetUserRoles();             //Special order is applied

            foreach (var role in roles)
            {
                RoleOptions.Add(new SelectOption(role.Id.ToString(), role.Name));
                var keyValuesObj = new KeyStringList()
                {
                    Key    = role.Id.ToString(),
                    Values = new List <string>()
                };
                if (ErpEntity.RecordPermissions.CanCreate.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("create");
                }
                if (ErpEntity.RecordPermissions.CanRead.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("read");
                }
                if (ErpEntity.RecordPermissions.CanUpdate.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("update");
                }
                if (ErpEntity.RecordPermissions.CanDelete.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("delete");
                }

                valueGrid.Add(keyValuesObj);
            }
            RecordPermissions = JsonConvert.SerializeObject(valueGrid);
            #endregion

            #region << Actions >>

            if (ErpEntity.System)
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.Disabled, label: "Delete locked", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "ti-trash", titleText: "System objects cannot be deleted"));
            }
            else
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.ConfirmAndSubmitForm, label: "Delete Entity", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "ti-trash go-red"));
            };

            HeaderActions.Add($"<a href='/sdk/objects/entity/m/{(ErpEntity != null ? ErpEntity.Id : Guid.Empty)}/manage?returnUrl={HttpUtility.UrlEncode(CurrentUrl)}' class='btn btn-white btn-sm'><i class='ti-settings go-orange'></i> Manage</a>");

            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "details"));

            #endregion
        }
예제 #6
0
        public void InitPage()
        {
            Init();

            var entMan = new EntityManager();

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;
            if (ErpEntity == null)
            {
                return;
            }

            Field = ErpEntity.Fields.FirstOrDefault(x => x.Id == RecordId);
            if (Field == null)
            {
                return;
            }

            var allCards = AdminPageUtils.GetFieldCards();

            FieldCard = allCards.First(x => (string)x["type"] == ((int)Field.GetFieldType()).ToString());


            #region << Init RecordPermissions >>
            var valueGrid = new List <KeyStringList>();
            PermissionOptions = new List <SelectOption>()
            {
                new SelectOption("read", "read"),
                new SelectOption("update", "update")
            };

            var roles = AdminPageUtils.GetUserRoles();             //Special order is applied

            foreach (var role in roles)
            {
                RoleOptions.Add(new SelectOption(role.Id.ToString(), role.Name));
                var keyValuesObj = new KeyStringList()
                {
                    Key    = role.Id.ToString(),
                    Values = new List <string>()
                };
                if (Field.Permissions.CanRead.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("read");
                }
                if (Field.Permissions.CanUpdate.Contains(role.Id))
                {
                    keyValuesObj.Values.Add("update");
                }
                valueGrid.Add(keyValuesObj);
            }
            FieldPermissions = JsonConvert.SerializeObject(valueGrid);
            #endregion

            #region << Actions >>
            if (Field.System)
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.Disabled, label: "Delete Locked", formId: "DeleteRecord", iconClass: "ti-trash", titleText: "System objects cannot be deleted"));
            }
            else
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.ConfirmAndSubmitForm, label: "Delete Field", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "ti-trash go-red"));
            };
            HeaderActions.Add($"<a href='/sdk/objects/entity/r/{(ErpEntity != null ? ErpEntity.Id : Guid.Empty)}/rl/fields/m/{Field.Id}' class='btn btn-white btn-sm'><i class='ti-settings go-orange'></i> Manage</a>");
            #endregion

            ApiUrlFieldInlineEdit = ErpSettings.ApiUrlTemplateFieldInlineEdit.Replace("{entityName}", ErpEntity.Name).Replace("{recordId}", (RecordId ?? Guid.Empty).ToString());
        }
예제 #7
0
        public void InitPage(bool isGet = true)
        {
            IsPostgisInstalled = DbRepository.IsPostgisInstalled();

            var entMan = new EntityManager();

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;

            var allCards = AdminPageUtils.GetFieldCards();

            if (FieldTypeId == 20) //RelationField
            {
                throw new Exception("RelationField is unsupported field type");
            }

            FieldCard = allCards.First(x => (string)x["type"] == FieldTypeId.ToString());

            if (Enum.TryParse <FieldType>(FieldTypeId.ToString(), out FieldType result))
            {
                Type = result;
            }

            if (isGet)
            {
                #region << Field Type init >>
                switch (Type)
                {
                case FieldType.AutoNumberField:
                    DisplayFormat = "{0}";
                    break;

                case FieldType.CurrencyField:
                    CurrencyOptions = Helpers.GetAllCurrency().MapTo <SelectOption>();
                    break;

                case FieldType.DateTimeField:
                    Format = "yyyy-MMM-dd HH:mm";
                    break;

                case FieldType.GeographyField:
                {
                    foreach (int format in Enum.GetValues(typeof(GeographyFieldFormat)))
                    {
                        string value = format.ToString();
                        string name  = ((GeographyFieldFormat)format).ToString();
                        GeographyFormats.Add(new SelectOption(value, name));
                    }
                }
                break;

                default:
                    break;
                }

                #endregion

                #region << Init RecordPermissions >>
                var valueGrid = new List <KeyStringList>();
                PermissionOptions = new List <SelectOption>()
                {
                    new SelectOption("read", "read"),
                    new SelectOption("update", "update")
                };

                var roles = AdminPageUtils.GetUserRoles(); //Special order is applied

                foreach (var role in roles)
                {
                    RoleOptions.Add(new SelectOption(role.Id.ToString(), role.Name));
                    var keyValuesObj = new KeyStringList()
                    {
                        Key    = role.Id.ToString(),
                        Values = new List <string>()
                    };
                }

                #endregion
            }

            #region << Actions >>

            if (Type != FieldType.GeographyField)
            {
                HeaderActions.AddRange(new List <string>()
                {
                    PageUtils.GetActionTemplate(PageUtilsActionType.SubmitForm, label: "Create Field", formId: "CreateRecord", btnClass: "btn btn-green btn-sm", iconClass: "fa fa-plus"),
                    PageUtils.GetActionTemplate(PageUtilsActionType.Cancel, returnUrl: ReturnUrl)
                });
            }
            else if (Type == FieldType.GeographyField)
            {
                if (IsPostgisInstalled)
                {
                    HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.SubmitForm, label: "Create Field", formId: "CreateRecord", btnClass: "btn btn-green btn-sm", iconClass: "fa fa-plus"));
                }

                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.Cancel, returnUrl: ReturnUrl));
            }
            #endregion
        }