bitshares / bitshares-ui

Fully featured Graphical User Interface / Reference Wallet for the BitShares Blockchain
https://wallet.bitshares.org
MIT License
518 stars 570 forks source link

[24][TBAPI-0KA] Open Orders Tab: Group By "Trading Pair" #2592

Closed fractalnode closed 5 years ago

fractalnode commented 5 years ago

I would like to propose some improvements in Open Orders Tab I currently have many open orders on many diferent markets and I'm always looking to find answers for few questions:

Additionally I would like to be able to:

I am attaching two mockups below. I think that the accordion would be great for this purpose.

Open-Orders

Screenshot_1

froooze commented 5 years ago

Good idea, can this be merged with #1666 ?

startailcoon commented 5 years ago

Very interesting idea, indeed. Would most likely be doable, and a good reason to look on a possible way of #1666.

Those mockups will be a good start for anyone looking at this.

Should include:

TBAPI-0KA commented 5 years ago

Please assign to me.

startailcoon commented 5 years ago

@TBAPI-0KA I've assigned you.

gibbsfromncis commented 5 years ago

@TBAPI-0KA, cc @startailcoon

I would like to ask you @TBAPI-0KA to follow my personal requirements when you work on a tasks which relates somehow to UI part:

1) We use only ant framework - http://ant.design but using our personal wrapper (style-guide): Live: https://styleguide.bitshares.org/#/dark Github: https://github.com/bitshares/bitshares-ui-style-guide - there you can find all integrated components which we support from ant.design framework.

If you can't find some component you need please let me know and I'll add them.

2) When you work with old components (like in your case) please replace all of them by ant components.

3) Please follow component-container pattern (for e.g. - https://medium.com/teamsubchannel/react-component-patterns-e7fb75be7bb0)

If it affects on your estimate please provide yours.

gibbsfromncis commented 5 years ago

@TBAPI-0KA Just for example in your case you should use 3 ant components:

startailcoon commented 5 years ago

As well described by Gibbs, this would indeed include changes of the existing components to bitshares-ui-style-guide (ANT). The hours on this is a rough estimate, so please return back if you find it not enough.

TBAPI-0KA commented 5 years ago

@startailcoon Sure. My typical workflow is to start the work, spent as little time as possible, and see if any estimate correction is required. From my conversation with @gibbsfromncis regarding this issue, I see that some refactoring of existing functionality (orders table should be transferred to ANT first) will be required additionally. At this point, I don't think that it will take more than 2 hours more, but let you know for sure when will dive deeper into the code.

TBAPI-0KA commented 5 years ago

@gibbsfromncis cc @startailcoon

I've spent around 3 hours until this point. Things look a little bit more complicated than I expected. There are some questions which are related to Ant usage and refactoring.

The first issue is related to the combination of Table and Collapse from Ant. On the one hand, Ant components are very smart and have a lot of properties. On the other hand, customization is very limited. For this task, the table header acts as a collapsible element. However, the Table component doesn't support such behavior. Putting Table inside of Collapsible component will break the relation between table header and body, in terms of DOM elements. I see the following ways how to handle this:

  1. Put content inside Collapsible header separately, or as a separate table. This will break alignment between header and body, which, in my opinion, kinda breaks the original idea, where summary is displayed under each column. But that's the easiest way to go, and this approach will not increase estimate over 6 hours I mentioned initially.
  2. Put a table with fixed columns width inside Collapsible as a header, and the same table with data as Collapsible content. This should help with alignment between header and body. However, it may break responsivity, or cause other UI issues. I'd not use this approach. Also, this requires a try to say will it affect estimate or not.
  3. Not use Collapsible at all. Instead, wrap a Table inside our own reusable CollapsibleTable component. I'm not sure how extendable Ant components are. Perhaps, some dirty hacks will be required. Maybe, it's not even possible at all, without breaking primary Table functionality itself. Also, this will definitely increase the estimate a little. However, I'd give a try to this approach anyway, since it's strategically better - we can reuse this component in other places.

The second issue is more complicated. I've implemented some basic UI for the table, and thought that I all I need to do is to change data format, used in the current implementation, to the data format accepted by the Ant's Table. And I was quite surprised - instead of JS objects and function/services that do calculations on the original data, I found that data array is populated with a set of React elements, which accept 14 parameters, and, internally, is a large mix of calculations and layout. It's easier to show than explain: https://github.com/bitshares/bitshares-ui/blob/develop/app/components/Account/AccountOrders.jsx#L216-L234 https://github.com/bitshares/bitshares-ui/blob/develop/app/components/Exchange/MyOpenOrders.jsx#L102-L346 Again, I see the following options:

  1. The Table contains the property named "expandedRowRender", which allows passing ReactNode as a table row. I can wrap existing OrderRow component. Not sure how smoothly this will work. Most likely, it will, but will require some styling fixes, and minor logic ones. In terms of implementation/estimate - this approach has the slightest impact. However, in fact, Ant components will be used only formally - OrderRow concentrates most of the logic here.
  2. Do a basic refactoring of OrderRow, for our particular cases. I'd separate every single table cell into a separate component, and of course separate data calculation logic. It's more than 200 lines of code, so this will increase the estimate for at least 6 hours.
  3. Do a complete refactoring. OrderRow is used in a few more places, i.e. My Orders on Exchange. I don't like passing variables like a bool one named "dashboard", which affects component rendering depending on the place used. However, this is much bigger and complicated task than the initial one and has almost no impact on the functionality. I can't even estimate it correctly at this point- it might be up to 20 hours and more.

Of course, it's possible to use the old approach (without Ant) for both issues. I don't know which are our priorities - do we need as many features as possible ASAP, or are we concentrated on refactoring and strategical benefits? @gibbsfromncis, could you look to this, please, and tell me what to do?

gibbsfromncis commented 5 years ago

@startailcoon this comment requires investigation from my part. I'll take a look on it more detailed today and provide you a summary

gibbsfromncis commented 5 years ago

@TBAPI-0KA Is it possible to use nested tables from ant - https://ant.design/components/table/#components-table-demo-nested-table as a solution for Table Collapse?

For TableRow let's use option #2 .

Please, before to start provide your estimate to finish this task

startailcoon commented 5 years ago

I see this implementation as a good thing, I support extended hours for this. Just post your rough estimate once you and Gibbs have a good idea on how to realize this issue.

Please use @gibbsfromncis to bounce ideas on this as he's well versed on Ant Components and can assist you.

TBAPI-0KA commented 5 years ago

@gibbsfromncis I've tried the Nested Tables approach. It looks really ugly even if one column of the nested table has different width:

However, I've built a PoC of custom CollapsibleTable component. In fact, it's almost completed, because I wanted to be sure that no hacks will be used. I was able to create such a reusable component, with nice code inside, and fully-supported API from regular Ant's Table.

So, regarding the estimate, here's a breakdown: Primary task functionality - 6 hours. This includes different data format calculation (partially), replacement of regular tables with the Ant ones, multiple tables with grouping, group order canceling per table, styling fixes. Collapsible Table component - 2 hours. Discussed earlier. Partial OrderRow refactoring - 6 hours. Includes splitting into different components between Account and other usages, data format calculation (second part), refactoring of separated Account component. Total - 14 hours. It's in terms of Qualified Hours - in fact, this will take around 16-20 hours in total.

startailcoon commented 5 years ago

If this comes out as good as you describe it, I'm all go for an increased estimate for it. Looking forward to see your work.

cc @gibbsfromncis @sschiessl-bcp

TBAPI-0KA commented 5 years ago

@startailcoon Well, it's always easy to check how good it comes out when the code is committed, right? Sorry for the delay - PR (#2686) is ready now. The short list of changes is presented in the description there.

However, in total it took me more time than I expected initially. 32 hours and 4 minutes of pure tracked development time, without counting communication, etc. I have a more detailed report with a breakdown, if necessary. There are a few reasons for such amount of time spent:

I'd like to stop on the latest one in more details, to explain why my implementation is fuller:

I understand that I extended the initial estimate quite a lot, and some of the core devs would do the same changes faster just because they know some common parts of the project much better than me. I feel uncomfortable to ask about something more, but, on the other hand, I also have a feeling that this is important and nicely done piece of work, which simplifies further support. So, I'm not asking about something significant. But if somebody of you guys can quickly look at the code, estimate the changes and how much you think they should fairly take, and there's a window for some extra hours - I'd really appreciate that.

Also, if possible, could this one be included in the 190510 milestone, please?

Some things (thoughts/known issues/questions) that lie out of the scope of this task, but are related:

sschiessl-bcp commented 5 years ago

Thanks for the detailed description! Considering the change of scope, your learning curve and the refactoring issue, what is your suggestion as a bounty?

TBAPI-0KA commented 5 years ago

If you ask about facts, after all the fixes and changes, I've spent 34 hours and 32 minutes on development in total, and 4 hours and 45 minutes on the communication. A fair amount of hours lies out somewhere between 14 and 35. If you ask about my opinion, I think qualified dev with good project knowledge (I assume that's what you mean by learning curve here?) would save 2-4 hours because of this knowledge. Also, around 4-5 hours were spent on things that didn't work and weren't included in any commits - i.e. I've tried few approaches on Collapsible Table animation principle before finding acceptable one in terms of performance, best practices, code clarity, and complexity. The rest of the time was spent quite effectively.

startailcoon commented 5 years ago

It looks good, and it seems quick in response when used with an account with lots of open and active trades.

The new layout looks good imho. Only thing is, as you've noted, the headers of the collapsed tables that aren't aligned compared to each other. Due to the limitations and requirements of this issue I still find this acceptable. You've made a good result based on the limitations of the components, I'm impressed.

The non-grouped table looks good with the changes.

Since the work done was larger than expected, and I'm not surprised, I'd like to offer an increased bounty hour for you. Let me discuss with the team and Stefan, that did the reviewed, and I'll return with an update for you.

TBAPI-0KA commented 5 years ago

I agree with you regarding alignment. I think this should be fixed somehow. My idea was not to blow up the scope further but create smaller issues instead. This would give more clarity in terms of how much time which particular things take. If you like to, please create a separate issue, and you can assign it to me right over. I'll make all the changes required. However, the question is "how this should be changed?". Please refer to the second point of my comment on the PR discussion: https://github.com/bitshares/bitshares-ui/pull/2686#issuecomment-492079778 It contains much more details regarding why this happens, and what are the options. In short - empty space should be distributed by some rules. The only reason why you haven't noticed this earlier in the non-grouped mode is that some columns in this mode divide empty space between them. This way, these gaps aren't so noticeable, but they are still present.

sschiessl-bcp commented 5 years ago

We have discussed your issue and agreed to a bounty of 24. I hope this meets your expectations, please do voice if not.

We are very happy with your delivery and quality, and would be very happy if you continue to contribute!

TBAPI-0KA commented 5 years ago

I think it's a fair amount.

I'm glad you're happy with what I'm doing. I like to work on this project as well. For me, sometimes it's quite complicated to understand the exact requirements of the various issues, and I hardly understand how the priorities are defined. So, please ping me directly if you have any decent piece of work. I think with discussions with @gibbsfromncis I'm capable to do a task of almost any complexity. Except probably something which heavily relies on the internal business logic rules, but I'll tell you in this case before doing anything on it.

sschiessl-bcp commented 5 years ago

I think it's a fair amount.

I'm glad you're happy with what I'm doing. I like to work on this project as well. For me, sometimes it's quite complicated to understand the exact requirements of the various issues, and I hardly understand how the priorities are defined. So, please ping me directly if you have any decent piece of work. I think with discussions with @gibbsfromncis I'm capable to do a task of almost any complexity. Except probably something which heavily relies on the internal business logic rules, but I'll tell you in this case before doing anything on it.

This one comes to mind #1908