dubeaud / bugnet

BugNET is an open source issue tracker built with .NET
189 stars 166 forks source link

Time Tracking Comments Required. #95

Closed gilmaxter closed 9 years ago

gilmaxter commented 9 years ago

I am wondering if it is possible to make the Comments a requirement instead of optional for time tracking.

If I am looking at the code correctly I suspect the comment field is this: bn:HtmlEditor ID="CommentHtmlEditor" Height="200" runat="server"

And I am wondering if there is any type of requirements i can add on to it like this:

asp:RegularExpressionValidator Display = "Dynamic" ControlToValidate = "CommentHtmlEditor" ID="RegularExpressionValidator" ValidationExpression = "^[\s\S]{8,}$" runat="server" ErrorMessage="Minimum 8 characters required." asp:RegularExpressionValidator

I do not know if regular expressions work on this, and my server is down at the moment so i cannot test this at the moment. And being new to C#-asp.net, I am just wondering if i can make the Comments in the time tracking section for adding time entry's a required field.

Thank you.

dubeaud commented 9 years ago

You can add a required field validator on the TimeTracking.ascx user control that forces a user to enter the comment. https://github.com/dubeaud/bugnet/blob/master/src/BugNET_WAP/Issues/UserControls/TimeTracking.ascx

The html editor is a seperate user control, and you may need to get the specific ID of the textbox that it renders to put in the ControlToValidate field.

/asp:RequiredFieldValidator This would be the only change necessary and wouldn't require a recompilation of the code.
gilmaxter commented 9 years ago

What is the specific ID then for the text Box because that is the page i was looking at all i can see that seems close is the bn:HtmlEditor ID="CommentHtmlEditor" Height="200" runat="server"

Would the ID be the CommentHtmlEditor ? because after that is the button, and before the bn is the label. So i am kinda lost on where it is at. When i render the page i get this id but not sure if it is accurate but i see a textarea with this ID below:

ctl00$ctl00$ctl00$MainContent$Content$IssueTabs$ctlIssueTabs$TabTimeTracking$CommentHtmlEditor$CommentHtmlEditor

dubeaud commented 9 years ago

Try this Id if the one you posted doesn't work. MainContent_ctlIssueTabs_TabTimeTracking_CommentHtmlEditor_CommentHtmlEditor

gilmaxter commented 9 years ago

thank you,

okay will try it as soon as my server machine is back online - (hate my ups) to verify just add this under line 55:

asp:RequiredFieldValidator runat="server" id="reqCommentForTracking" controltovalidate="MainContent_ctlIssueTabs_TabTimeTracking_CommentHtmlEditor_CommentHtmlEditor" errormessage="Please enter on the comment field" />

and that would make comments a requirement for time tracking without the need to recompile code ?

gilmaxter commented 9 years ago

tried it out with both Id's and sadly it isn't working. whenever i go to the time tracking the panel will not show up.... Here is the code so far

asp:RequiredFieldValidator SetFocusOnError="True" runat="server" ID="RequiredFieldValidator50" controltovalidate="MainContent_ctlIssueTabs_TabTimeTracking_CommentHtmlEditor_CommentHtmlEditor" errormessage="Please enter on the comment field" > /asp:RequiredFieldValidator>

is there something i can do with maybe this, I am just wondering if i can try a required validator or something with it.?

asp:BoundColumn DataField="CommentText" HeaderText="Comment"></asp:BoundColumn

dubeaud commented 9 years ago

Did you miss the ValidationGroup="AddTimeEntry" property on the required field? It won't be triggered for adding a time entry if it is not present.

gilmaxter commented 9 years ago

Yes i did , but now its just sending me to the error page for some reaason here is what i added to the field now.

<asp:RequiredFieldValidator SetFocusOnError="True" ValidationGroup="AddTimeEntry" runat="server" ID="RequiredFieldValidator50" controltovalidate="MainContent_ctlIssueTabs_TabTimeTracking_CommentHtmlEditor_CommentHtmlEditor" errormessage="Please enter on the comment field" ></asp:RequiredFieldValidator>
dubeaud commented 9 years ago

You can disable customErrors in the web.config or check the error log to get the error. The tag you posted is missing brackets at the beginning and the end which would cause it to error.

gilmaxter commented 9 years ago

I know its missing brackets I left it out on purpose because the preview shows it doing something odd, i will disable the customErrors now on web.config

gilmaxter commented 9 years ago

well i did this on the web config.

and now all the page does when i go to the time tracking is... Nothing. Nothing loads up no errors but no information.Here is the information with brackets this time I do not know what i am doing wrong.

<asp:RequiredFieldValidator SetFocusOnError="True" ValidationGroup="AddTimeEntry" runat="server"  Display="Dynamic" ID="RequiredFieldValidator50" ControlToValidate="MainContent_ctlIssueTabs_TabTimeTracking_CommentHtmlEditor_CommentHtmlEditor" ErrorMessag=" *" ></asp:RequiredFieldValidator>
dubeaud commented 9 years ago

Change it to

<customErrors defaultRedirect="~/Errors/Error.aspx" mode="Off" />
gilmaxter commented 9 years ago

I set the option to Off on the web.config. Where is the error log event located ?

dubeaud commented 9 years ago

When you get an error it will be displayed directly on the page now to troubleshoot.

gilmaxter commented 9 years ago

darn, was afraid of that, nothing has changed in the page. Going to the tab for time tracking doesn't display any errors. It just doesn't display at all. I can switch between tabs, it just leaves what was in the current tab when i go to the time tracker.

Update: Well removing the required field validator made the time tracker section show up.... I guess there has to be something off with it still... Here is the code for it. By the way i also tried it with and without the # on the control to validate. the error page is working, removing a important information and leaving out a comma did made the error page work. but now its not showing any errors but the tab is not working. I even replaced required field to regular expressions and still nothing.

<div class="col-md-10">
        <bn:HtmlEditor ID="CommentHtmlEditor" Height="200" runat="server" />
        <asp:RequiredFieldValidator SetFocusOnError="True" ValidationGroup="AddTimeEntry" runat="server" ControlToValidate="#ctl00_ctl00_ctl00_MainContent_Content_IssueTabs_ctlIssueTabs_TabTimeTracking_CommentHtmlEditor_CommentHtmlEditor" ErrorMessag=" *" ></asp:RequiredFieldValidator>
    </div>

with the regular expression

<asp:RegularExpressionValidator SetFocusOnError="True" ValidationGroup="AddTimeEntry" runat="server" ControlToValidate="MainContent_ctlIssueTabs_TabTimeTracking_CommentHtmlEditor_CommentHtmlEditor"  ValidationExpression="^[a-zA-Z'.\s]{1,40}$" ErrorMessag=" *" ></asp:RegularExpressionValidator>
dubeaud commented 9 years ago

The ID is probably not correct in this instance than the way the ckeditor works. It might just need the id of the editor itself "CommentHtmlEditor"

gilmaxter commented 9 years ago

okay now this is something. Changing it to CommentHtmlEditor allowed the page to load up. but for some reason I can still submit a blank comment field.

gilmaxter commented 9 years ago

I changed the id from bn:HtmlEditor ID to this asp:TextBox ID="CommentHtmlEditor" runat="server" CssClass="form-control" MaxLength="10"

But for some reason i am getting this error.

Parser Error Message: The base class includes the field 'CommentHtmlEditor', but its type (BugNET.UserControls.HtmlEditor) is not compatible with the type of control (System.Web.UI.WebControls.TextBox).

What can i use for asp.net besides TextBox to just solve this issue ?

dubeaud commented 9 years ago

To change the editor you need to get into the code and then recompile the application.

gilmaxter commented 9 years ago

peachy... Well got the source for it and figured out i can add this line of code keeping everything else the same.

protected void AddTimeEntry_Click(object sender, EventArgs e)
    {

        // Makes comment text a requirement
        if (CommentHtmlEditor.Text.Trim().Length == 0) return;
        ....

Now that i have the updated the code and changed the html to a textbox what is the next step ? I know i have to move the TimeTracker.ascx file but is there anything else i have to move over

gilmaxter commented 9 years ago

alrighty got it done. thank you for your help. Once the changes were made i just needed to look for the right bugnet.dll and from there on it was simple to add it in to my server and take care of that issue thank you.

dubeaud commented 9 years ago

Glad you got it resolved. Cheers.