Ejemplo n.º 1
0
        protected override async Task OnParametersSetAsync()
        {
            if (JsonConvert.SerializeObject(_originalValue) != JsonConvert.SerializeObject(Value))
            {
                _originalValue = Value;
                if (Value == null)
                {
                    _value = null;
                }
                else
                {
                    _value = JsonConvert.DeserializeObject <WvpFileInfo>(JsonConvert.SerializeObject(Value));
                }
            }

            if (!String.IsNullOrWhiteSpace(Placeholder))
            {
                AdditionalAttributes["placeholder"] = Placeholder;
            }

            if (!String.IsNullOrWhiteSpace(Title))
            {
                AdditionalAttributes["title"] = Title;
            }

            await base.OnParametersSetAsync();
        }
Ejemplo n.º 2
0
        private async Task _toggleInlineEditClickHandler(bool enableEdit, bool applyChange)
        {
            //Show Edit
            if (enableEdit && !_editEnabled)
            {
                _editEnabled = true;
            }

            //Hide edit
            if (!enableEdit && _editEnabled)
            {
                //Apply Change
                if (applyChange)
                {
                    if (_value != _originalValue)
                    {
                        //Update Function should be called
                        await ValueChanged.InvokeAsync(new ChangeEventArgs { Value = _value });
                    }
                }
                //Abandon change
                else
                {
                    _value = _originalValue;
                }
                _editEnabled = false;
            }
            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 3
0
        protected override async Task OnParametersSetAsync()
        {
            if (JsonConvert.SerializeObject(_originalValue) != JsonConvert.SerializeObject(Value))
            {
                _originalValue = Value;
                if (Value == null)
                {
                    _value = null;
                }
                else
                {
                    var jsonSettings = new JsonSerializerSettings {
                        TypeNameHandling = TypeNameHandling.All, TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Full
                    };
                    jsonSettings.Converters.Insert(0, new PrimitiveJsonConverter());
                    _value = JsonConvert.DeserializeObject <WvpFileInfo>(JsonConvert.SerializeObject(Value, Formatting.None, jsonSettings), jsonSettings);
                }
            }

            if (!String.IsNullOrWhiteSpace(Placeholder))
            {
                AdditionalAttributes["placeholder"] = Placeholder;
            }

            if (!String.IsNullOrWhiteSpace(Title))
            {
                AdditionalAttributes["title"] = Title;
            }

            await base.OnParametersSetAsync();
        }
Ejemplo n.º 4
0
        private async Task _removeFile()
        {
            _value = null;
            await ValueChanged.InvokeAsync(new ChangeEventArgs { Value = _value });

            await OnInput.InvokeAsync(new ChangeEventArgs { Value = _value });

            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 5
0
 private async Task _removeFile(WvpFileInfo file)
 {
     _value.Remove(file);
     ValueChanged.InvokeAsync(new ChangeEventArgs {
         Value = _value
     });
     OnInput.InvokeAsync(new ChangeEventArgs {
         Value = _value
     });
     await InvokeAsync(StateHasChanged);
 }
Ejemplo n.º 6
0
		public static WvpFileInfo FilePathToWvpFormFile(string filePath)
		{
			var result = new WvpFileInfo
			{
				ContentType = FilePathToMimeType(filePath),
				Id = 0,
				LastModified = DateTime.Now,
				Name = FilePathToFileName(filePath),
				Url = filePath,
				Size = 0
			};
			return result;
		}
Ejemplo n.º 7
0
        protected override async Task OnParametersSetAsync()
        {
            _cssList = new List <string>();

            if (!String.IsNullOrWhiteSpace(Class))
            {
                _cssList.Add(Class);
                if (!Class.Contains("form-control"))
                {                //Handle input-group case
                    _cssList.Add("form-control-plaintext");
                    if (Value == null)
                    {
                        _cssList.Add("form-control-plaintext--empty");
                    }
                }
            }
            else
            {
                _cssList.Add("form-control-plaintext");
                if (Value == null)
                {
                    _cssList.Add("form-control-plaintext--empty");
                }
            }

            var sizeSuffix = Size.ToDescriptionString();

            if (!String.IsNullOrWhiteSpace(sizeSuffix))
            {
                _cssList.Add($"form-control-{sizeSuffix}");
            }

            if (JsonConvert.SerializeObject(_originalValue) != JsonConvert.SerializeObject(Value))
            {
                _originalValue = Value;
                if (Value == null)
                {
                    _value = null;
                }
                else
                {
                    var jsonSettings = new JsonSerializerSettings {
                        TypeNameHandling = TypeNameHandling.All, TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Full
                    };
                    jsonSettings.Converters.Insert(0, new PrimitiveJsonConverter());
                    _value = JsonConvert.DeserializeObject <WvpFileInfo>(JsonConvert.SerializeObject(Value, Formatting.None, jsonSettings), jsonSettings);
                }
            }

            await base.OnParametersSetAsync();
        }
Ejemplo n.º 8
0
 private async Task _onInputHandler(ChangeEventArgs e)
 {
     //On Input will be executed after Keydown so we need to apply any scheduled changes here
     if (scheduledEnableEditChange != null && scheduledApplyChange != null)
     {
         await _toggleInlineEditClickHandler(scheduledEnableEditChange.Value, scheduledApplyChange.Value);
     }
     else
     {
         //Apply value only if a change is not scheduled
         _value = (WvpFileInfo)e.Value;
     }
     await InvokeAsync(StateHasChanged);
 }
Ejemplo n.º 9
0
        public async Task UpdateProgressAsync(WvpFileInfo fileInfo)
        {
            var fileIndex = -1;

            if (_value != null)
            {
                _value.FindIndex(x => x.Name == fileInfo.Name);
            }
            if (fileIndex > -1)
            {
                _value[fileIndex] = fileInfo;
                await InvokeAsync(StateHasChanged);
            }
        }
        protected override async Task OnParametersSetAsync()
        {
            _cssList = new List <string>();

            if (!String.IsNullOrWhiteSpace(Class))
            {
                _cssList.Add(Class);
                if (!Class.Contains("form-control"))
                {                //Handle input-group case
                    _cssList.Add("form-control-plaintext");
                    if (Value == null)
                    {
                        _cssList.Add("form-control-plaintext--empty");
                    }
                }
            }
            else
            {
                _cssList.Add("form-control-plaintext");
                if (Value == null)
                {
                    _cssList.Add("form-control-plaintext--empty");
                }
            }

            var sizeSuffix = Size.ToDescriptionString();

            if (!String.IsNullOrWhiteSpace(sizeSuffix))
            {
                _cssList.Add($"form-control-{sizeSuffix}");
            }

            if (JsonConvert.SerializeObject(_originalValue) != JsonConvert.SerializeObject(Value))
            {
                _originalValue = Value;
                if (Value == null)
                {
                    _value = null;
                }
                else
                {
                    _value = JsonConvert.DeserializeObject <WvpFileInfo>(JsonConvert.SerializeObject(Value));
                }
            }

            await base.OnParametersSetAsync();
        }
Ejemplo n.º 11
0
        protected override async Task OnParametersSetAsync()
        {
            _cssList = new List <string>();

            if (!String.IsNullOrWhiteSpace(Class))
            {
                _cssList.Add(Class);
            }

            var sizeSuffix = Size.ToDescriptionString();

            if (!String.IsNullOrWhiteSpace(sizeSuffix))
            {
                _cssList.Add($"form-control-{sizeSuffix}");
            }

            if (JsonConvert.SerializeObject(_originalValue) != JsonConvert.SerializeObject(Value))
            {
                _originalValue = Value;
                _value         = null;
                if (Value is WvpFileInfo)
                {
                    var jsonSettings = new JsonSerializerSettings {
                        TypeNameHandling = TypeNameHandling.All, TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Full
                    };
                    jsonSettings.Converters.Insert(0, new PrimitiveJsonConverter());
                    _value = JsonConvert.DeserializeObject <WvpFileInfo>(JsonConvert.SerializeObject(Value, Formatting.None, jsonSettings), jsonSettings);
                }
            }

            if (!String.IsNullOrWhiteSpace(Name))
            {
                AdditionalAttributes["name"] = Name;
            }

            if (!String.IsNullOrWhiteSpace(Placeholder))
            {
                AdditionalAttributes["placeholder"] = Placeholder;
            }

            if (!String.IsNullOrWhiteSpace(Title))
            {
                AdditionalAttributes["title"] = Title;
            }

            await base.OnParametersSetAsync();
        }
Ejemplo n.º 12
0
        protected override async Task OnParametersSetAsync()
        {
            _cssList = new List <string>();

            if (!String.IsNullOrWhiteSpace(Class))
            {
                _cssList.Add(Class);
            }

            var sizeSuffix = Size.ToDescriptionString();

            if (!String.IsNullOrWhiteSpace(sizeSuffix))
            {
                _cssList.Add($"form-control-{sizeSuffix}");
            }

            if (JsonConvert.SerializeObject(_originalValue) != JsonConvert.SerializeObject(Value))
            {
                _originalValue = Value;
                _value         = null;
                if (Value is WvpFileInfo)
                {
                    _value = JsonConvert.DeserializeObject <WvpFileInfo>(JsonConvert.SerializeObject(Value));
                }
            }

            if (!String.IsNullOrWhiteSpace(Name))
            {
                AdditionalAttributes["name"] = Name;
            }

            if (!String.IsNullOrWhiteSpace(Placeholder))
            {
                AdditionalAttributes["placeholder"] = Placeholder;
            }

            if (!String.IsNullOrWhiteSpace(Title))
            {
                AdditionalAttributes["title"] = Title;
            }

            await base.OnParametersSetAsync();
        }
Ejemplo n.º 13
0
        public async Task NotifyChange(List <WvpFileInfo> files)
        {
            _value = null;
            if (files.Count > 0)
            {
                _value = files[0];
            }

            foreach (var file in files)
            {
                if (file == null)
                {
                    file.Status = "File not found";
                    await InvokeAsync(StateHasChanged);

                    return;
                }
                else if (file.Size > MaxFileSize)
                {
                    file.Status = $"That's too big. Max size: {WvpHelpers.GetSizeStringFromSize(MaxFileSize)}";
                    await InvokeAsync(StateHasChanged);

                    return;
                }
                else
                {
                    file.Status = "Loading...";
                }

                await file.WriteTempFileAsync(JSRuntime, _elementRef, UpdateProgressAsync);
            }
            await ValueChanged.InvokeAsync(new ChangeEventArgs { Value = _value });

            await OnInput.InvokeAsync(new ChangeEventArgs { Value = _value });

            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 14
0
 public async Task UpdateProgressAsync(WvpFileInfo fileInfo)
 {
     _value = fileInfo;
     await InvokeAsync(StateHasChanged);
 }