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); }
public IView <HTMLElement> Create(RemoteFileDescr forFile, Action forceAddOrRemoveToView) { var widget = InputTypeButtonActionView.CreateFontAwesomeIconedAction( IconFontType.FontAwesomeSolid, FontAwesomeSolid.IconTimes); widget.Widget.Title = I18n.Translate("Hide"); widget.Triggered += () => _parent.OnRemoveTransient(forFile); UpdateVisibility(forFile, widget); _known.Add(forFile, widget); return(widget); }
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); }