Spree Deface: how to insert a column into a table? - spree

I need to add a column to a table in Spree's Admin backend. There is a data-hook on each <tr>.
So in theory I can insert_top a <td> on each row (and also insert a <th> in the <thead> and a <col> in the <colgroup>).
Is this the best way, or is there a better way?

This is fairly easy to achieve using a few small files with the new .deface DSL. Eg with HAML (assuming Spree::Order has a custom attribute called distributor)
Header:
/ insert_top "[data-hook='admin_orders_index_headers']"
%th
Distributor
Rows:
/ insert_top "[data-hook='admin_orders_index_rows']"
%td.align-center
= order.distributor.name
If you want to alter the column widths, it's often easier just to overwrite the colgroup:
/ replace_contents "table#listing_orders colgroup"
%col{style: "width: 10%"}
...etc

Related

Oracle Apex Interactive Grid Cell Format

Basic question please, I have an IG.
Trying to format a column using the following:
SELECT
CASE
WHEN my_number <= 3 THEN 'u-color-7-bg'
WHEN my_number > 3 THEN 'u-color-8-bg'
END some_color
FROM my_table
I'm modifying the resulting column 'some_color' to be an HTML Expression type.
On its HTML Expression part I have:
< span style="color: &SOME_COLOR.">&MY_NUMBER.< /span>
But it doesn't work, no format is getting applied whatsoever.
Can anybody give me a hand please?
u-color-xx are CSS classes not actual colors. It should work if you try <span class="&SOME_COLOR.">&MY_NUMBER.</span> instead.
Alternatively you can use CSS-Variables defined by APEX in newer versions like this: <span style="background: var(--u-color-35)">&MY_NUMBER.</span>

Removing zero quantity items from Netsuite Picking Ticket Advanced PDF

I am new to NetSuite and my current role. Our warehouse team is strunggling with Picking Tickets coming through with zero quantity items among a long list of items to be picked.
Pickers are making mistakes and picking items for which an order has not been placed. The original problem is with the Sales Order which is being worked on by others.
I am trying to find a quick solution whereby when picking tickets are printed the zero quantity items are filtered out and not printed.
Really appreciate any help provided.
Try this "SHOW UNCOMMITTED ITEMS ON PICKING TICKETS"
Navigation: setup--> Accounting-->Accounting preferences-->order management
If anyone else comes across this, you can also add this code to the PDF template in the case where you still need the uncommitted line items in Netsuite but just not printed on the PDF:
<thead>
<tr>
<th>...</th>
<tr/>
</thead>
<!-- only line items with qty > 0 on Sales Order will print -->
<#if item.quantity gt 0>
<tr>
<td>...</td>
</tr>
</#if>

Convert HTML Table to plain Text in Power BI

I am a beginner in power BI. I have to create a report with share point data. I have imported the data into dataset. However, some columns have text with html table tags or style like below -
<div class="ExternalClass5DA0D04953B047459697675F266FEABF">
<p>​</p>
<table width="395" border="0" cellspacing="0" cellpadding="0" style="width:296pt;">
<tbody>
<tr height="115" style="height:86.4pt;">
<td width="395" height="115" class="xl64" style="width:296pt;height:86.4pt;">
I am working on issue. I shall update the progress. <br>
</td>
</tr>
</tbody>
</table>
<p><br></p>
</div>
But I would like to show the plain text only which is "I am working on issue. I shall update the progress."
From this community thread, you can find a handy function for stripping all the HTML tags:
Here's the core logic (ignoring the documentation metadata for readability):
let func = (HTML) =>
let
Check = if Value.Is(Value.FromText(HTML), type text) then HTML else "",
Source = Text.From(Check),
SplitAny = Text.SplitAny(Source,"<>"),
ListAlternate = List.Alternate(SplitAny,1,1,1),
ListSelect = List.Select(ListAlternate, each _<>""),
TextCombine = Text.Combine(ListSelect, "")
in
TextCombine
in
func
Having this handy bit of code, create a new blank query and paste the above code into the advanced editor and give it a name, say, TextFromHTML.
Once you have that function defined, you can use it in any of your queries. For example, here's what a step to transform the column ColWithHTML might look like:
Table.TransformColumns(#"Prior Step", {{"ColWithHTML", each TextFromHTML(_), type text}})
You can create a new column with below formula as show below
if [HMTLField] = null then null else Html.Table([HMTLField] , {{"text",":root"}})
Then click on the button on right top of the field to convert this field as text by expanding it.

EmberJS - {{moment-format 'date' 'output' 'input'}} repeats todays date in every row when used in {{#each} block

I am using ember-moment addon in order to format the dates in the following table:
<tbody>
{{#each model as |model|}}
<tr class="clickable-row">
<td>{{model.id}}</td>
<td>{{model.first_name}}</td>
<td>{{model.last_name}}</td>
<td>{{model.date_of_birth}}</td>
<td>{{model.inserted_at}}</td>
<td>{{model.departed_at}}</td>
</tr>
{{/each}}
</tbody>
date_of_birth property returned from the DB ha the following format:
yyyy-mm-ddThh:mm:ss+|-hhmm
When I try to format it like below;
{{moment-format 'model.date_of_birth' 'DD/MM/YYYY' 'yyyy-mm-ddThh:mm:ss+|-hhmm' }}
I end up with a populated table full of unique rows, except the date of birth is just today's date on every single row.
I know I am missing something obvious and someone out there is going to make me look very silly!
You should pass binding date object to the helper instead of passing its name as a string. Therefore use it like this:
{{moment-format model.date_of_birth 'DD/MM/YYYY' }}

Change <td> to <th> in first row of a HTML table server side using Cold Fusion

I am sending a HTML string to the Cold Fusion (9) server. The string contains a HTML table with multiple rows. Since the table doesn't have a head I need to change the <td>s of the first row into <th>s.
For your information:
The code to change is a paste code coming from MS Word. The code gets sent to the server to check if there are any tables in it. If yes, there is an option dialog shown to the user where he can descide how the table will be formatted (striped, hovers and so on).
In my opinion the best way to do that would be ReReplace(). But I can't figure what the right regex can be.
Any suggestions on that will be much appreciated.
The code looks like:
<table class="table">
<tbody>
<tr><td>Head 1</td><td>Head 2</td><td>Head 3</td></tr>
<tr><td>Content 1 Row 1</td><td>Content 2 Row 1</td><td>Content 3 Row 1</td></tr>
<tr><td>Content 1 Row 2</td><td>Content 2 Row 2</td><td>Content 3 Row 2</td></tr>
</tbody>
</table>
And should look like:
<table class="table">
<tbody>
<tr><th>Head 1</th><th>Head 2</th><th>Head 3</th></tr>
<tr><td>Content 1 Row 1</td><td>Content 2 Row 1</td><td>Content 3 Row 1</td></tr>
<tr><td>Content 1 Row 2</td><td>Content 2 Row 2</td><td>Content 3 Row 2</td></tr>
</tbody>
</table>
Thanks in advance.
Obligatory warning: maybe a parser or as #npinti suggested changing the output in the first place is a far better way to go.
That being said, you could use a lazy quantifier (expensive!) between the <td> tags and feed the function chunks of <table> parts and substitute it with <th>\2</th> (see the regex 101 demo for an example).
(<td>(.*?)<\/td>)
Hint: This does not take additional attributes into account (e.g. class="test123").