diff --git a/src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs b/src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs index 1b16aad54d8..6be477404f0 100644 --- a/src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs @@ -31,6 +31,42 @@ namespace Dynamo.PackageManager { public delegate void PublishSuccessHandler(PublishPackageViewModel sender); + + /// + /// Keyword tag displaying under the keyword input text box + /// + public class KeywordTag : NotificationObject + { + /// + /// Name of the host + /// + public string Name { get; set; } + + private bool _onChecked; + /// + /// Triggers the remove action + /// + public bool OnChecked + { + get { return _onChecked; } + set + { + _onChecked = value; + + RaisePropertyChanged(nameof(OnChecked)); + } + } + + /// + /// Constructor + /// + /// Keyword name + public KeywordTag(string name) + { + Name = name; + } + } + /// /// The ViewModel for Package publishing public class PublishPackageViewModel : NotificationObject @@ -269,6 +305,22 @@ public string Keywords } } + private ObservableCollection keywordsCollection = new ObservableCollection(); + + /// + /// A collection of dynamic non-hosted filters + /// such as New, Updated, Deprecated, Has/HasNoDependencies + /// + public ObservableCollection KeywordsCollection + { + get { return keywordsCollection; } + set + { + keywordsCollection = value; + RaisePropertyChanged(nameof(KeywordsCollection)); + } + } + /// /// KeywordList property /// @@ -635,6 +687,11 @@ public string MarkdownFilesDirectory /// A command which, when executed, submits the current package public DelegateCommand ToggleMoreCommand { get; private set; } + /// + /// Sets the keywords tags based on the current KeywordList items + /// + public DelegateCommand SetKeywordsCommand { get; private set; } + /// /// The package used for this submission /// @@ -838,6 +895,7 @@ internal PublishPackageViewModel() CancelCommand = new DelegateCommand(Cancel); RemoveItemCommand = new Dynamo.UI.Commands.DelegateCommand(RemoveItem); ToggleMoreCommand = new DelegateCommand(() => MoreExpanded = !MoreExpanded, () => true); + SetKeywordsCommand = new DelegateCommand(SetKeywords, CanSetKeywords); Dependencies.CollectionChanged += DependenciesOnCollectionChanged; Assemblies = new List(); MarkdownFiles = new List(); @@ -948,19 +1006,6 @@ private List BindParentToChild(Dictionary /// Test if path2 is subpath of path1 /// If it is, make sure all the intermediate file paths are created as separte PackageItemRootViewModel @@ -1034,7 +1079,7 @@ private void ClearAllEntries() // Clearing the UploadHandle when using Submit currently throws - check trheading try { - this._uploadHandle.PropertyChanged += UploadHandleOnPropertyChanged; + this._uploadHandle.PropertyChanged -= UploadHandleOnPropertyChanged; this.UploadHandle = null; } catch { Exception ex; } @@ -1113,6 +1158,29 @@ private void ThisPropertyChanged(object sender, PropertyChangedEventArgs e) } } + private bool CanSetKeywords() + { + return KeywordList.Count() > 0; + } + private void SetKeywords() + { + KeywordsCollection = KeywordList.Select(x => new KeywordTag(x)).ToObservableCollection(); + foreach (var keyword in KeywordsCollection) + { + keyword.PropertyChanged += Keyword_PropertyChanged; + } + } + + private void Keyword_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (!(sender is KeywordTag keyword)) return; + if (e.PropertyName == nameof(KeywordTag.OnChecked)) + { + keyword.PropertyChanged -= Keyword_PropertyChanged; + KeywordsCollection.Remove(keyword); + } + } + public static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoViewModel, Package l) { var defs = new List(); diff --git a/src/DynamoCoreWpf/Views/PackageManager/Controls/FilterTagControl.xaml b/src/DynamoCoreWpf/Views/PackageManager/Controls/FilterTagControl.xaml index 92241a7049b..1aeb2132a7e 100644 --- a/src/DynamoCoreWpf/Views/PackageManager/Controls/FilterTagControl.xaml +++ b/src/DynamoCoreWpf/Views/PackageManager/Controls/FilterTagControl.xaml @@ -23,8 +23,7 @@ ToggleDefaultBrush="{StaticResource MidBlueBrush}" ToggleHoverBrush="{StaticResource MidDarkBlueBrush}" TogglePressedBrush="{StaticResource MidLightBlueBrush}" /> - + - + + + + + + - - + + - - + + diff --git a/src/DynamoCoreWpf/Views/PackageManager/Pages/PublishPackagePublishPage.xaml b/src/DynamoCoreWpf/Views/PackageManager/Pages/PublishPackagePublishPage.xaml index 9328f9c9257..eee76117d9d 100644 --- a/src/DynamoCoreWpf/Views/PackageManager/Pages/PublishPackagePublishPage.xaml +++ b/src/DynamoCoreWpf/Views/PackageManager/Pages/PublishPackagePublishPage.xaml @@ -543,7 +543,33 @@ Style="{StaticResource InputStyle}" Text="{Binding Keywords, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Tag="{x:Static p:Resources.PublishPackageKeywordsWatermark}" - TabIndex="7" /> + TabIndex="7"> + + + + + + + + + + + + + + + + + + + + + + + + +