Skip to content

Commit

Permalink
Replace tags TextBox with ListBox and source tags list from TagContro…
Browse files Browse the repository at this point in the history
…ller
  • Loading branch information
Eric Wagner committed Feb 5, 2021
1 parent 65590ff commit d609bd9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 31 deletions.
5 changes: 2 additions & 3 deletions ucSubmitNews.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,8 @@
</tr>
<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" />
<td>
<asp:ListBox ID="lstTags" runat="server" CssClass="Normal" DataTextField="Name" DataValueField="Name" Width="300px" SelectionMode="Multiple" />
</td>
</tr>
</table>
Expand Down
13 changes: 2 additions & 11 deletions ucSubmitNews.ascx.designer.vb

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

52 changes: 35 additions & 17 deletions ucSubmitNews.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ Namespace Ventrian.NewsArticles
li.Selected = True
End If
Next
txtTags.Text = objArticle.Tags

SelectTags(objArticle.Tags)

Dim objPageController As New PageController
Dim pages As ArrayList = objPageController.GetPageList(_articleID)
Expand Down Expand Up @@ -336,6 +337,31 @@ Namespace Ventrian.NewsArticles

End Sub

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

objTags.Sort()
lstTags.DataSource = objTags
lstTags.DataBind()
End Sub

Private Sub SelectTags(ByVal tagList As String)
Dim objTagController As New TagController
For Each tag As String In tagList.Split(","c)
If (tag <> "") Then
Dim objTag As TagInfo = objTagController.Get(ModuleId, tag)

If Not (objTag Is Nothing) Then
Dim li As ListItem = lstTags.Items.FindByValue(objTag.Name)
If Not (li Is Nothing) Then
li.Selected = True
End If
End If
End If
Next
End Sub

Private Sub BindCustomFields()

Dim objCustomFieldController As New CustomFieldController()
Expand Down Expand Up @@ -1145,31 +1171,22 @@ Namespace Ventrian.NewsArticles
Dim objLinkedArticle As ArticleInfo = objArticleController.GetArticle(Convert.ToInt32(drpMirrorArticle.SelectedValue))

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

Dim objTagController As New TagController
objTagController.DeleteArticleTag(articleID)

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
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)
End If
Next
End If
End If
Next

End Sub

Expand Down Expand Up @@ -1517,6 +1534,7 @@ Namespace Ventrian.NewsArticles

BindStatus()
BindCategories()
BindTags()
SetVisibility()
BindArticle()
SetValidationGroup()
Expand Down

0 comments on commit d609bd9

Please sign in to comment.