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); }
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); }); }
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); }
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; }