Recent

Author Topic: Visual PlanIt problems with resources.  (Read 3089 times)

kkuba

  • Jr. Member
  • **
  • Posts: 50
Visual PlanIt problems with resources.
« on: October 08, 2023, 08:37:34 pm »
And I detected resource problems. First, we have what looks like a critical bug: Datastore.DeleteResource(res) deletes a resource instead of marking it as inactive. As a result, we get a beautiful inconsistency of data in the database if there are events. Such a curiosity is to be found in FullDemo.
Permanent deletion of resources could be considered (but in my opinion it is still a big mistake) if there was an alternative in accessing the resourceactive field in the resources table. There isn't... You would have to manually enter values into the database. Be careful with this because the demo example is misleading and can permanently damage the SQL database - there is no warning in the code that this is some kind of terrible makeshift.
Secondly what is already less serious is that we have an annoying bug in ResourceEditDialog. When we call Execute and edit a resource, the description cannot be corrected without changing the resource name. Otherwise, a nonsensical message appears saying that the resource already exists. Of course, this applies to AddNewResource, not Execute, just missing an if.
« Last Edit: October 10, 2023, 09:07:07 am by kkuba »

wp

  • Hero Member
  • *****
  • Posts: 13486
Re: Visual PlanIt problems with resources.
« Reply #1 on: October 11, 2023, 12:27:22 am »
Fixed in SVN. Please test (file-based datastores not yet working).

kkuba

  • Jr. Member
  • **
  • Posts: 50
Re: Visual PlanIt problems with resources.
« Reply #2 on: October 12, 2023, 10:44:18 am »
I checked and the translation worked except for my small error in the demo.pl file. The fix is attached.

VpGanttViewis is a good option, but the ability to change the orientation of the component should probably be added. Without this it cannot be used for work teams.

The error with editing a resource using the VpResourceEditDialog component is fixed. As I understand the problem with deleting the resource is left - it is not a bug in the code but in the logic of TVPlainIt. You just have to keep it in mind, because correcting it requires big changes.

Instead, I discovered problems with VpResourceCombo. There is some glitch that causes the component to set on the second resource(?) after adding / changing resources.  If there is only one resource then the component sets on nothing. In general, this causes it to be difficult to determine on which resource the component sets itself after starting the application or changing the list of resources. Some random things happen. The problem is increased by the fact that the ItemIndex property is not implemented in VpResourceCombo. Of course, it is possible to use the property from TcustomComboBox, but this has no right to work. It only changes the description, not the resource itself. Probably something should be improved to allow setting what appears on VpResourceCombo after Create or Repaint. Perhaps by handling the ItemIndex property, or some other way.
Another bug in VpResourceCombo is that DataStore is published as a property, while it should be VpControlLink. This is confusing and leads to errors in the code.

I have a small request to @WP regarding VpDayView, which defaults to 7 a.m. These days it's offices that don't start work that way. Would it be possible to add some property that would set the start time? At my place work starts at 10 and this 7 is very annoying, you have to scroll the calendar .at the start every time you change the day.
« Last Edit: October 12, 2023, 11:06:37 am by kkuba »

wp

  • Hero Member
  • *****
  • Posts: 13486
Re: Visual PlanIt problems with resources.
« Reply #3 on: October 12, 2023, 01:25:40 pm »
VpGanttViewis is a good option, but the ability to change the orientation of the component should probably be added. Without this it cannot be used for work teams.
You mean to draw the bars running downward? This would require a massive change in the component, I will not do this. And all the Gantt charts that I've seen so far are running horizontally. The main issue is that the events then are positioned horizontally, but the available space is very much limited because of the wide event text.

The error with editing a resource using the VpResourceEditDialog component is fixed. As I understand the problem with deleting the resource is left - it is not a bug in the code but in the logic of TVPlainIt. You just have to keep it in mind, because correcting it requires big changes.
Sorry I don't understand what you mean. It must be possible to delete a resource. The issue was that this deletion (which was still the original code from TurboPower) did not respect referential integrity and left events, tasks and contacts untouched, and resulted in lots of orphaned records. Now all events, tasks and contacts are deleted along with their resource.

Instead, I discovered problems with VpResourceCombo. There is some glitch that causes the component to set on the second resource(?) after adding / changing resources.  If there is only one resource then the component sets on nothing. In general, this causes it to be difficult to determine on which resource the component sets itself after starting the application or changing the list of resources. Some random things happen. The problem is increased by the fact that the ItemIndex property is not implemented in VpResourceCombo. Of course, it is possible to use the property from TcustomComboBox, but this has no right to work. It only changes the description, not the resource itself. Probably something should be improved to allow setting what appears on VpResourceCombo after Create or Repaint. Perhaps by handling the ItemIndex property, or some other way.
I tend to think of the TvPlanIt controls in the same way as with visual database controls: they are only visual representation of the data, the data themselves reside in the datastore (or database) and should be handled there. Therefore, I prefer to start up a TvPlanIt application with a specific resource by specifying this resource in the OnCreate handler of the form, rather than indirectly by the items of the resource combobox. In the "fulldemo" the ID of the active resource is stored in the application's ini file:
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.FormCreate(Sender: TObject);
  2. begin
  3.   ...
  4.   ReadIni;      // contains this:  FResID := ini.ReadInteger('Data', 'ResourceID', -1);
  5.   ...
  6.   with VpControlLink1.DataStore do
  7.   begin
  8.     if (Resources.Count > 0) then begin
  9.       if FResID = -1 then
  10.         Resource := Resources.Items[0]
  11.       else
  12.         ResourceID := FResID;
  13.     end;
  14.     ..
  15.   end;
  16.   ...
  17. end;

Another bug in VpResourceCombo is that DataStore is published as a property, while it should be VpControlLink. This is confusing and leads to errors in the code.
What is the problem? Please explain. Since resource selection is something which belongs to the datastore I do not see why this should cause trouble. VpControlLink, on the other hand, is some higher component controlling also the printer and some default settings. I don't understand why the resource combo should need them.

I have a small request to @WP regarding VpDayView, which defaults to 7 a.m. These days it's offices that don't start work that way. Would it be possible to add some property that would set the start time? At my place work starts at 10 and this 7 is very annoying, you have to scroll the calendar .at the start every time you change the day.
Did you see the property DefaultTopHour? It specifies the time at which the dayview begins by default. The earlier times, however, still are available by scrolling.

kkuba

  • Jr. Member
  • **
  • Posts: 50
Re: Visual PlanIt problems with resources.
« Reply #4 on: October 12, 2023, 11:23:39 pm »
As for VpGanttViewis. I didn't expect you to do this. I just expressed my opinion that it was probably necessary for my purpose. :) I also acknowledge that it is difficult to implement.

As for deleting the resource. I stick to my opinion. The solution you introduced is ok, but it should be treated as an emergency solution, not the main one. In my opinion, the correct way to implement delete in a SQL database for a user (not for an administrator) is to mark the resource as inactive and leave the entries. But that's right, you corrected the code - I don't question that. I guess we just have different opinions - which is perfectly acceptable. :)

As for DefaultTopHour. My fault - I didn't notice this feature, thanks, that's what I asked.

As for VpResourceCombo. You're right, I forgot about it, and Resource := Resources.Items[...] redirects VpResourceCombo. It was in the example, I saw it and forgot it. My fault.

I don't understand the rest of what you write. The closest to VpResourceCombo is DBLookupComboBox. There is only the DataSource property, because the reference to the DataSet only confuses - exactly the opposite of what you write. There is also a Key property that is writable, which is the less or more equivalent of ItemIndex. In TVPlanIt you can have different DataSet settings in VpResourceCombo and VpControLink. I don't understand this idea. But maybe there is a case for doing things differently than in Data Controls. But I don't know why.

VpResourceCombo is a similar component and has nothing like Key. For me VpResourceCombo is now something strange, especially since it is based on TCustomComboBox. Either this should be similar to ComboBox or DBLookupComboBox. Now it is neither one way nor the other. Of course, you may have a different opinion - as I wrote above. :)
« Last Edit: October 13, 2023, 01:13:47 am by kkuba »

wp

  • Hero Member
  • *****
  • Posts: 13486
Re: Visual PlanIt problems with resources.
« Reply #5 on: October 13, 2023, 01:30:25 am »
I don't understand the rest of what you write.
Sorry. Just wanted to mention the similar case when users want to adjust database output by tweaking properties of the DBGrid rather than addressing it in the database directly. Not important - forget it.

 

TinyPortal © 2005-2018