Esempio n. 1
0
        public void CanHide_should_throw_exception_if_not_found()
        {
            var command = new HideField {
                FieldId = 3
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardSchemaField.CanHide(schema_0, command));
        }
Esempio n. 2
0
        public void CanHide_hould_not_throw_exception_if_visible()
        {
            var command = new HideField {
                FieldId = 1
            };

            GuardSchemaField.CanHide(schema_0, command);
        }
Esempio n. 3
0
        public void CanHide_should_throw_exception_if_ui_field()
        {
            var command = new HideField {
                FieldId = 4
            };

            Assert.Throws <DomainException>(() => GuardSchemaField.CanHide(command, schema_0));
        }
Esempio n. 4
0
        public SchemaDomainObject HideField(HideField command)
        {
            VerifyCreatedAndNotDeleted();

            RaiseEvent(command, new FieldHidden());

            return(this);
        }
Esempio n. 5
0
        protected Task On(HideField command, CommandContext context)
        {
            return(handler.UpdateSyncedAsync <SchemaDomainObject>(context, s =>
            {
                GuardSchemaField.CanHide(s.Snapshot.SchemaDef, command);

                s.HideField(command);
            }));
        }
Esempio n. 6
0
        public void CanHide_should_throw_exception_if_already_hidden()
        {
            var command = new HideField {
                FieldId = 1
            };

            schema.FieldsById[1].Hide();

            Assert.Throws <DomainException>(() => GuardSchemaField.CanHide(schema, command));
        }
        public async Task <IActionResult> HideField(string app, string name, long id)
        {
            var command = new HideField {
                FieldId = id
            };

            await CommandBus.PublishAsync(command);

            return(NoContent());
        }
Esempio n. 8
0
        public async Task <IActionResult> HideNestedField(string app, string name, long parentId, long id)
        {
            var command = new HideField {
                ParentFieldId = parentId, FieldId = id
            };

            var response = await InvokeCommandAsync(app, command);

            return(Ok(response));
        }
Esempio n. 9
0
        public void CanHide_should_throw_exception_if_locked()
        {
            var command = new HideField {
                FieldId = 1
            };

            var schema_1 = schema_0.UpdateField(1, f => f.Lock());

            Assert.Throws <DomainException>(() => GuardSchemaField.CanHide(command, schema_1));
        }
Esempio n. 10
0
        public async Task <IActionResult> HideField(string app, string name, long id)
        {
            var command = new HideField {
                FieldId = id
            };

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
Esempio n. 11
0
        public void CanHide_should_throw_exception_if_already_hidden()
        {
            var command = new HideField {
                FieldId = 1
            };

            var schema_1 = schema_0.HideField(1);

            Assert.Throws <DomainException>(() => GuardSchemaField.CanHide(schema_1, command));
        }
Esempio n. 12
0
        public static void CanHide(HideField command, Schema schema)
        {
            Guard.NotNull(command);

            var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false);

            if (!field.IsForApi(true))
            {
                throw new DomainException("UI field cannot be hidden.");
            }
        }
Esempio n. 13
0
        public static void CanHide(Schema schema, HideField command)
        {
            Guard.NotNull(command, nameof(command));

            var field = GetFieldOrThrow(schema, command.FieldId);

            if (field.IsHidden)
            {
                throw new DomainException("Schema field is already hidden.");
            }
        }
Esempio n. 14
0
        public static void CanHide(HideField command, Schema schema)
        {
            Guard.NotNull(command, nameof(command));

            var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false);

            if (!field.IsForApi(true))
            {
                throw new DomainException(T.Get("schemas.uiFieldCannotBeHidden"));
            }
        }
Esempio n. 15
0
        public SchemaDomainObject HideField(HideField command)
        {
            Guard.NotNull(command, nameof(command));

            VerifyCreatedAndNotDeleted();

            SchemaFieldGuard.GuardCanHide(schema, command.FieldId);

            RaiseEvent(command, new FieldHidden());

            return(this);
        }
Esempio n. 16
0
        void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    UpdateField();
                    HideField?.Invoke();
                }
            }

            catch (FieldTitelException ea)
            {
                ShowErrorMessage(ea.Message);
            }
        }
Esempio n. 17
0
        public static void CanHide(Schema schema, HideField command)
        {
            Guard.NotNull(command, nameof(command));

            var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false);

            if (field.IsHidden)
            {
                throw new DomainException("Schema field is already hidden.");
            }

            if (!field.IsForApi())
            {
                throw new DomainException("UI field cannot be hidden.");
            }
        }
Esempio n. 18
0
        public async Task HideField_should_create_events_and_update_state()
        {
            var command = new HideField { FieldId = 1 };

            await ExecuteCreateAsync();
            await ExecuteAddFieldAsync(fieldName);

            var result = await sut.ExecuteAsync(CreateCommand(command));

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.True(GetField(1).IsHidden);

            LastEvents
                .ShouldHaveSameEvents(
                    CreateEvent(new FieldHidden { FieldId = fieldId })
                );
        }
Esempio n. 19
0
        public async Task HideField_should_create_events_and_update_state_for_array()
        {
            var command = new HideField { ParentFieldId = 1, FieldId = 2 };

            await ExecuteCreateAsync();
            await ExecuteAddArrayFieldAsync();
            await ExecuteAddFieldAsync(fieldName, 1);

            var result = await sut.ExecuteAsync(CreateCommand(command));

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.True(GetNestedField(1, 2).IsHidden);

            LastEvents
                .ShouldHaveSameEvents(
                    CreateEvent(new FieldHidden { ParentFieldId = arrayId, FieldId = nestedId })
                );
        }
Esempio n. 20
0
 void cmdCancel_Click(object sender, EventArgs e)
 {
     HideField?.Invoke();
 }
 protected Task On(HideField command, CommandContext context)
 {
     return(handler.UpdateAsync <SchemaDomainObject>(context, s => s.HideField(command)));
 }
    /// <summary>
    /// 创建Grid
    /// </summary>
    /// <param name="dt"></param>
    public string  CreateGrid()
    {
        StringBuilder sb = new StringBuilder();

        sb.Append("<table id=\"" + ID + "\" class=\"" + Cls + "\" cellpadding=\"0\" cellspacing=\"0\">\r\n");
        if (!string.IsNullOrEmpty(Title))
        {
            sb.Append("<thead>\r\n<tr  class=\"grid_title\">\r\n<th style=\"width:100%\"><span class=\"grid_title_span\">" + Title + "</span><span><a id=\"a_Delete\" href=\"javascript:void(0);\">Delete</a></span><span><a id=\"a_DeleteAll\" href=\"javascript:void(0);\">Del All</a></span></th></tr></thead>\r\n");
        }
        sb.Append("<tbody><tr class=\"grid_caption\"><td style=\"margin:0;padding:0\">\r\n<table cellpadding=\"0\" cellspacing=\"1\">\r\n<tr>\r\n");
        sb.Append("<th  style=\"width:25px\">No.</th>\r\n");
        for (int i = 0; i < Caption.Length; ++i)
        {
            if (!HideField.Contains(Caption[i].ToString()))
            {
                sb.Append("<th style=\"width:" + CWidth[i] + "\">" + Caption[i].ToString() + "</th>\r\n");
            }
            else
            {
                sb.Append("<th style=\"display:none;width:" + CWidth[i] + "\">" + Caption[i].ToString() + "</th>\r\n");
            }
        }
        sb.Append("<th style=\"width:16px;padding:0px;margin:0px;\"></th></tr></table></td></tr></tbody>\r\n<tbody><tr><td style=\"padding:0px;margin:0px\"><div class=\"grid_content_div\" style=\"\"><table class=\"grid_content\" cellpadding=\"0\" cellspacing=\"1\"><tbody>");

        if (dt != null && dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                sb.Append("\r\n<tr>\r\n<td style=\"width:25px; text-align:center\">" + (i + 1) + "</td>\r\n");
                for (int j = 0; j < FieldName.Length; ++j)
                {
                    if (HideField.Contains(Caption[j].ToString()))
                    {
                        sb.Append("<td  style=\"display:none; width:" + CWidth[j] + "\">" + CreateInput(DataType[j], dt.Rows[i][FieldName[j].ToString()].ToString(), CWidth[j], FieldName[j], i) + "</td>\r\n");
                    }
                    else
                    {
                        if (j == FieldName.Length)
                        {
                            sb.Append("<td>" + CreateInput(DataType[j], dt.Rows[i][FieldName[j].ToString()].ToString(), CWidth[j], FieldName[j], i) + "</td>\r\n");
                        }
                        else
                        {
                            sb.Append("<td  style=\"width:" + CWidth[j] + "\">" + CreateInput(DataType[j], dt.Rows[i][FieldName[j].ToString()].ToString(), CWidth[j], FieldName[j], i) + "</td>\r\n");
                        }
                    }
                }
                sb.Append("</tr>");
            }
        }
        for (int i = dt.Rows.Count; i < 30; ++i)
        {
            sb.Append("<tr>\r\n<td style=\"width:25px; text-align:center\">" + (i + 1) + "</td>\r\n");
            for (int j = 0; j < FieldName.Length; ++j)
            {
                if (!HideField.Contains(Caption[j].ToString()))
                {
                    if (j == FieldName.Length)
                    {
                        sb.Append("<td>" + CreateInput(DataType[j], dt.Rows[i][FieldName[j].ToString()].ToString(), CWidth[j], FieldName[j], i) + "</td>\r\n");
                    }
                    else
                    {
                        sb.Append("<td  style=\"width:" + CWidth[j] + "\">" + CreateInput(DataType[j], "", CWidth[j], FieldName[j], i) + "</td>\r\n");
                    }
                }
                else
                {
                    sb.Append("<td  style=\"display:none;width:" + CWidth[j] + "\">" + CreateInput(DataType[j], "", CWidth[j], FieldName[j], i) + "</td>\r\n");
                }
            }
            sb.Append("</tr>");
        }
        sb.Append("</tbody></table></div></td></tr></tbody></table>");
        return(sb.ToString());
    }
Esempio n. 23
0
 public void HideField(HideField command)
 {
     RaiseEvent(command, new FieldHidden());
 }
Esempio n. 24
0
 private void HideField(HideField command)
 {
     Raise(command, new FieldHidden());
 }