예제 #1
0
            public IView <HTMLElement> Create(RemoteFileDescr forFile, Action forceAddOrRemoveToView)
            {
                var widget = InputTypeButtonActionView.CreateFontAwesomeIconedAction(
                    IconFontType.FontAwesomeSolid, FontAwesomeSolid.IconExchangeAlt);

                widget.Widget.Title = I18n.Translate("Replace");
                widget.Triggered   += () => {
                    //HACK due to lack of: on input[file] activated but user declined to select anything
                    _parent._hackOnUploadStarted =
                        () => {
                        widget.State = ActionViewState.CreateOperationRunning();
                        _activatedFor.Add(forFile);
                    };

                    _parent.OnReplace(widget, forFile, forceAddOrRemoveToView);

                    _parent._hackOnUploadEnded = result => {
                        _activatedFor.Remove(forFile);
                        widget.Widget.TextContent = FontAwesomeSolid.IconExchangeAlt;
                        widget.State = result.Success ?
                                       ActionViewState.CreateIdleOrSuccess()
                            :
                                       ActionViewState.CreateOperationFailed(new Exception(result.ErrorMessage));

                        UpdateEnablement(forFile, widget, false); //make action enabled (needed due to hack above)
                    };
                };
                UpdateEnablement(forFile, widget, false);
                _known.Add(forFile, widget);
                return(widget);
            }
예제 #2
0
 private void UpdateEnablement(
     RemoteFileDescr forFile, bool isOperationStarted, IView <HTMLElement> senderOrNull)
 {
     _known
     .Where(x => x.Key == forFile)
     .ForEach(x => {
         if (x.Value != senderOrNull)
         {
             //reset former errors if any
             x.Value.State = ActionViewState.CreateIdleOrSuccess();
         }
         UpdateEnablement(x.Key, x.Value, isOperationStarted);
     });
 }
예제 #3
0
            public IView <HTMLElement> Create(RemoteFileDescr forFile, Action forceAddOrRemoveToView)
            {
                var widget = InputTypeButtonActionView.CreateFontAwesomeIconedAction(
                    IconFontType.FontAwesomeSolid, FontAwesomeSolid.IconTrashAlt);

                widget.Widget.Title = I18n.Translate("Remove");
                widget.Triggered   += async() => {
                    widget.State = ActionViewState.CreateOperationRunning();
                    var result = await _parent.OnRemove(widget, forFile, forceAddOrRemoveToView);

                    widget.Widget.TextContent = FontAwesomeSolid.IconTrashAlt;
                    widget.State = result.Success ?
                                   ActionViewState.CreateIdleOrSuccess()
                        :
                                   ActionViewState.CreateOperationFailed(new Exception(result.ErrorMessage));
                };

                UpdateEnablement(forFile, widget, false);

                _known.Add(forFile, widget);
                return(widget);
            }
예제 #4
0
 public void OnShown()
 {
     _view.Confirm.State = ActionViewState.CreateIdleOrSuccess(); //don't show former error
 }
 public void Init(IEnumerable <T> permittedValues)
 {
     _view.Confirm.State = ActionViewState.CreateIdleOrSuccess();
     _localValue.Reset(false, this);
     _view.Choosen.PermittedValues = permittedValues;
 }