Skip to content

Commit

Permalink
Create UseStaticTagsList ArticleSetting and enable SubmitNews view to…
Browse files Browse the repository at this point in the history
… toggle between TextBox and ListBox for tags
  • Loading branch information
Eric Wagner committed Feb 5, 2021
1 parent e6b572c commit 0a740ae
Show file tree
Hide file tree
Showing 9 changed files with 452 additions and 328 deletions.
6 changes: 6 additions & 0 deletions App_LocalResources/ucViewOptions.ascx.resx
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@
<data name="CategorySettings.Text" xml:space="preserve">
<value>Category Settings</value>
</data>
<data name="TagSettings.Text" xml:space="preserve">
<value>Tag Settings</value>
</data>
<data name="DefaultCategories.Help" xml:space="preserve">
<value>Check categories to auto-select them on the create article screen.</value>
</data>
Expand Down Expand Up @@ -1134,6 +1137,9 @@
<data name="CategoryFilterSubmit.Text" xml:space="preserve">
<value>Filter Category Submit</value>
</data>
<data name="UseStaticTagsList.Text" xml:space="preserve">
<value>Use Static Tags List</value>
</data>
<data name="AllGroups.Text" xml:space="preserve">
<value>-- All Groups -- </value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions Components/ArticleSettings.vb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ Namespace Ventrian.NewsArticles
End Get
End Property

Public ReadOnly Property UseStaticTagsListSubmit() As Boolean
Get
If (Settings.Contains(ArticleConstants.USE_STATIC_TAGS_LIST_SUBMIT_SETTING)) Then
Return Convert.ToBoolean(Settings(ArticleConstants.USE_STATIC_TAGS_LIST_SUBMIT_SETTING).ToString())
Else
Return ArticleConstants.USE_STATIC_TAGS_LIST_SUBMIT_SETTING_DEFAULT
End If
End Get
End Property

Public ReadOnly Property IncludeInPageName() As Boolean
Get
If (Settings.Contains(ArticleConstants.CATEGORY_NAME_SETTING)) Then
Expand Down
3 changes: 3 additions & 0 deletions Components/Common/ArticleConstants.vb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ Namespace Ventrian.NewsArticles
Public Const CATEGORY_FILTER_SUBMIT_SETTING_DEFAULT As Boolean = False
Public Const CATEGORY_SORT_SETTING As String = "CategorySortType"
Public Const CATEGORY_SORT_SETTING_DEFAULT As CategorySortType = CategorySortType.SortOrder
Public Const USE_STATIC_TAGS_LIST_SUBMIT_SETTING As String = "UseStaticTagsList"
Public Const USE_STATIC_TAGS_LIST_SUBMIT_SETTING_DEFAULT As Boolean = False


' Category Security Settings
Public Const PERMISSION_CATEGORY_VIEW_SETTING As String = "PermissionCategoryView"
Expand Down
2 changes: 2 additions & 0 deletions ucSubmitNews.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@
<tr runat="Server" id="trTags">
<td class="SubHead" width="150"><dnn:label id="plTags" text="Tags:" runat="server" controlname="txtTags"></dnn:label></td>
<td>
<asp:textbox id="txtTags" cssclass="NormalTextBox" width="300" maxlength="255" runat="server" /><br />
<asp:Label ID="lblTags" ResourceKey="TagsHelp" runat="server" CssClass="Normal" />
<asp:ListBox ID="lstTags" runat="server" CssClass="Normal" DataTextField="Name" DataValueField="Name" Width="300px" Height="150px" SelectionMode="Multiple" />
</td>
</tr>
Expand Down
18 changes: 18 additions & 0 deletions ucSubmitNews.ascx.designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 50 additions & 13 deletions ucSubmitNews.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ Namespace Ventrian.NewsArticles
End If
Next

SelectTags(objArticle.Tags)
If (ArticleSettings.UseStaticTagsListSubmit) Then
SelectTags(objArticle.Tags)
Else
txtTags.Text = objArticle.Tags
End If


Dim objPageController As New PageController
Dim pages As ArrayList = objPageController.GetPageList(_articleID)
Expand Down Expand Up @@ -338,12 +343,19 @@ Namespace Ventrian.NewsArticles
End Sub

Private Sub BindTags()
Dim objTagController As New TagController
Dim objTags As ArrayList = objTagController.List(ModuleId, Null.NullInteger)
If (ArticleSettings.UseStaticTagsListSubmit) Then
txtTags.Visible = False
lblTags.Visible = False

Dim objTagController As New TagController
Dim objTags As ArrayList = objTagController.List(ModuleId, Null.NullInteger)

objTags.Sort()
lstTags.DataSource = objTags
lstTags.DataBind()
objTags.Sort()
lstTags.DataSource = objTags
lstTags.DataBind()
Else
lstTags.Visible = False
End If
End Sub

Private Sub SelectTags(ByVal tagList As String)
Expand Down Expand Up @@ -1171,22 +1183,47 @@ Namespace Ventrian.NewsArticles
Dim objLinkedArticle As ArticleInfo = objArticleController.GetArticle(Convert.ToInt32(drpMirrorArticle.SelectedValue))

If (objLinkedArticle IsNot Nothing) Then
SelectTags(objLinkedArticle.Tags)
If (ArticleSettings.UseStaticTagsListSubmit) Then
SelectTags(objLinkedArticle.Tags)
Else
txtTags.Text = objLinkedArticle.Tags
End If
End If
End If

Dim objTagController As New TagController
objTagController.DeleteArticleTag(articleID)

For Each li As ListItem In lstTags.Items
If (li.Selected) Then
Dim objTag As TagInfo = objTagController.Get(ModuleId, li.Value)
If (ArticleSettings.UseStaticTagsListSubmit) Then
For Each li As ListItem In lstTags.Items
If (li.Selected) Then
Dim objTag As TagInfo = objTagController.Get(ModuleId, li.Value)

If Not (objTag Is Nothing) Then
objTagController.Add(articleID, objTag.TagID)
If Not (objTag Is Nothing) Then
objTagController.Add(articleID, objTag.TagID)
End If
End If
Next
Else
If (txtTags.Text <> "") Then
Dim tags As String() = txtTags.Text.Split(","c)
For Each tag As String In tags
If (tag <> "") Then
Dim objTag As TagInfo = objTagController.Get(ModuleId, tag)

If (objTag Is Nothing) Then
objTag = New TagInfo
objTag.Name = tag
objTag.NameLowered = tag.ToLower()
objTag.ModuleID = ModuleId
objTag.TagID = objTagController.Add(objTag)
End If

objTagController.Add(articleID, objTag.TagID)
End If
Next
End If
Next
End If

End Sub

Expand Down
10 changes: 10 additions & 0 deletions ucViewOptions.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
</tr>
</table>
<br />
<dnn:sectionhead id="dshTags" cssclass="Head" runat="server" text="Tag Settings" resourcekey="TagSettings"
section="tblTags" isexpanded="False" />
<table id="tblTags" cellspacing="2" cellpadding="2" summary="Appearance Design Table"
border="0" runat="server">
<tr>
<td class="SubHead" width="200"><dnn:label id="Label12" runat="server" resourcekey="UseStaticTagsList" controlname="chkUseStaticTagsList"></dnn:label></td>
<td valign="top"><asp:checkbox id="chkUseStaticTagsList" Runat="server" CssClass="NormalTextBox"></asp:checkbox></td>
</tr>
</table>
<br />
<dnn:sectionhead id="dshComments" cssclass="Head" runat="server" text="Comment Settings" resourcekey="CommentSettings"
section="tblComments" isexpanded="False" />
<table id="tblComments" cellspacing="2" cellpadding="2" summary="Appearance Design Table"
Expand Down
Loading

0 comments on commit 0a740ae

Please sign in to comment.