Пример #1
0
        public ScriptView OnEdit(ScriptView view)
        {
            var sender = view.GetSender();
            var id     = sender.Data.Id;

            var data = ServiceContext.InvokeDynamic("getAccount", (arg) =>
            {
                arg.id = id;
            });

            data.Transform("roles.id=>value");
            data.Transform("roles.name=>text");
            data.Transform("rpassword=password");
            data.Transform("isEnabled=status.isEnabled");

            var form = view.GetElement <FormSE>("formEdit");

            form.Set(data);

            var modal = view.GetElement <ModalSE>("editDialog");

            modal.SetTitle(string.Format(Strings.ModifyAccountInformationTip, data.Dynamic.name));
            modal.Open();

            return(view);
        }
Пример #2
0
        public ScriptView OnSubmitEdit(ScriptView view)
        {
            var form = view.GetElement <FormSE>("formEdit");
            var data = form.Data;

            data.Transform("isEnabled=isEnabled", (t) =>
            {
                return(DataUtil.ToValue <bool>(t));
            });
            data.Transform("roles=>roleIds");

            ServiceContext.Invoke("updateAccount", data);

            MenuHelper.RemoveMenuCode(data.Dynamic.Id.ToString());

            var modal = view.GetElement <ModalSE>("editDialog");

            modal.Close();

            var grid = view.GetElement <DataTableSE>("list");

            grid.Reload();

            return(view);
        }
Пример #3
0
        public ScriptView OnAdd(ScriptView view)
        {
            var form = view.GetElement <FormSE>("formAdd");

            form.Reset();

            var modal = view.GetElement <ModalSE>("addDialog");

            modal.Open();

            return(view);
        }
Пример #4
0
        public ScriptView OnEdit(ScriptView view)
        {
            var sender = view.GetSender();
            var data   = sender.Data;
            var form   = view.GetElement <FormSE>("formEdit");

            form.Set(data);

            var modal = view.GetElement <ModalSE>("editDialog");

            modal.SetTitle(string.Format(Strings.EditFunction, data.name));
            modal.Open();

            return(view);
        }
Пример #5
0
        public ScriptView OnSubmitAdd(ScriptView view)
        {
            var form = view.GetElement <FormSE>("formAdd");
            var data = form.Data;

            ServiceContext.Invoke("addPermission", data);
            form.Reset();

            form.AlertSuccess(Strings.SavedSuccessfully);

            var grid = view.GetElement <DataTableSE>("list");

            grid.Reload();

            return(view);
        }
Пример #6
0
        private IScriptView OnScriptCallback(ScriptView view)
        {
            var grid = view.GetElement <DataTableSE>("list");

            grid.Load();
            return(view);
        }
Пример #7
0
        public ScriptView OnPaperMetadataSearch(ScriptView view)
        {
            var grid = view.GetElement <DataTableSE>("paperMetadatas");

            grid.Load();
            return(view);
        }
Пример #8
0
        public ScriptView OnSearch(ScriptView view)
        {
            var grid = view.GetElement <DataTableSE>("list");

            grid.Load();
            return(view);
        }
Пример #9
0
        private void Init(ScriptView view)
        {
            var data = ServiceContext.InvokeDynamic("getUser", (arg) => { arg.Id = Principal.Id; });

            data.Transform("email=account.email;mobileNumber=account.mobileNumber");

            var form = view.GetElement <FormSE>("baseForm");

            form.Set(data);

            var file = this.Template.GetFile("/Pages/MyProfile/images/photo.png");

            data.Dynamic.PhotoUrl = data.Dynamic.Photo != null?ImageUtil.GetDynamicUrl(data.Dynamic.Photo.StoreKey, 192, 192, 2)
                                        : file.VirtualPath;

            var card = view.GetElement <HtmlEelementSE>("card");

            card.Bind(data);
        }
Пример #10
0
        public ScriptView OnSubmitEdit(ScriptView view)
        {
            var form = view.GetElement <FormSE>("formEdit");
            var data = form.Data;

            ServiceContext.Invoke("updatePermission", data);

            MenuHelper.RemoveAllMenuCode();

            var modal = view.GetElement <ModalSE>("editDialog");

            modal.Close();

            var grid = view.GetElement <DataTableSE>("list");

            grid.Reload();

            return(view);
        }
Пример #11
0
        public ScriptView OnDeletes(ScriptView view)
        {
            var grid  = view.GetElement <DataTableSE>("list");
            var items = grid.SelectedValues;

            ServiceContext.Invoke("deleteRoles", items.ToReusableObject("ids"));

            MenuHelper.RemoveAllMenuCode();

            grid.Reload(items);
            return(view);
        }
Пример #12
0
        public ScriptView OnSubmitAdd(ScriptView view)
        {
            var form = view.GetElement <FormSE>("formAdd");
            var data = form.Data;

            data.Transform("isEnabled=isEnabled", (t) =>
            {
                return(DataUtil.ToValue <bool>(t));
            });
            data.Transform("roles=>roleIds");

            ServiceContext.Invoke("addUser", data);
            form.Reset();
            form.AlertSuccess(Strings.SavedSuccessfully);

            var grid = view.GetElement <DataTableSE>("list");

            grid.Reload();

            return(view);
        }
Пример #13
0
        protected virtual IScriptView Login(ScriptView view)
        {
            var form = view.GetElement <FormSE>("loginForm");
            var data = form.Data;

            data["ip"] = HttpContext.Current.Request.UserHostAddress;

            var      handler = ModuleController.GetHandler("login");
            DTObject dto     = handler.Process(data);

            var success = dto.GetValue <bool>("success");

            if (success)
            {
                form.Reset();
                view.Redirect(this.SuccessUrl);
            }
            else
            {
                view.GetElement("alertText").SetText(Strings.WrongUserNamePassword);
                view.GetElement("alert").Visible();
            }
            return(view);
        }
Пример #14
0
        public ScriptView OnBaseSubmit(ScriptView view)
        {
            var form = view.GetElement <FormSE>("baseForm");
            var data = form.Data;

            data["id"] = Principal.Id;

            ServiceContext.Invoke("updateUser", data);

            Init(view);

            form.AlertSuccess(Strings.SuccessfulOperation);

            return(view);
        }
Пример #15
0
        public ScriptView OnEdit(ScriptView view)
        {
            var sender = view.GetSender();
            var id     = sender.Data.Id;

            var data = ServiceContext.InvokeDynamic("getRole", (arg) =>
            {
                arg.id = id;
            });

            data.Transform("permissions.id=>value");
            data.Transform("permissions.name=>text");

            var form = view.GetElement <FormSE>("formEdit");

            form.Set(data);

            var modal = view.GetElement <ModalSE>("editDialog");

            modal.SetTitle(string.Format(Strings.EditRole, data.Dynamic.name));
            modal.Open();

            return(view);
        }
Пример #16
0
        private IScriptView UpdateUser(ScriptView view)
        {
            var e    = view.GetElement(this.Id);
            var data = e.Data;

            var getUser = ModuleController.GetHandler("user.detail");
            var info    = getUser.Process(para => {
                para["id"] = data.GetValue("userId");
            });

            var handler = ModuleController.GetHandler("user.update");

            info.SetValue("imageId", data.GetValue("photoId"));
            handler.Process(info);

            return(view);
        }
Пример #17
0
        private IScriptView Register(ScriptView view)
        {
            var form   = view.GetElement <FormSE>("registerForm");
            var data   = form.Data;
            var result = SignUp(data);

            if (result.Success)
            {
                view.WriteCode("SnippetLogin.displaySignInForm();");
                view.WriteCode(string.Format("$$('#loginForm').show('{0}');", Strings.OperationSucceededPleaseLogin));
            }
            else
            {
                view.WriteCode(string.Format("registerForm.proxy().showError('{0}');", result.Message));
            }
            return(view);
        }
Пример #18
0
        protected virtual IScriptView Login(ScriptView view)
        {
            var form = view.GetElement <FormSE>("loginForm");
            var data = form.Data;

            data["ip"] = HttpContext.Current.Request.UserHostAddress;

            var success = SignIn(data);

            if (success)
            {
                view.Redirect(this.SuccessUrl);
            }
            else
            {
                view.WriteCode(string.Format("loginForm.proxy().showError('{0}');", Strings.WrongUserNamePassword));
            }
            return(view);
        }
Пример #19
0
        public ScriptView OnAccountSubmit(ScriptView view)
        {
            var form = view.GetElement <FormSE>("accountForm");
            var data = form.Data;

            if (data.Dynamic.newPassword != data.Dynamic.rPassword)
            {
                throw new UserUIException(Strings.PasswordTip2);
            }

            data["id"] = Principal.Id;

            ServiceContext.Invoke("updatePassword", data);

            Init(view);

            form.AlertSuccess(Strings.SuccessfulOperation);

            return(view);
        }