10 Trello Card Background Color

How to add colors and background images to Trello boards in ..
How to add colors and background images to Trello boards in ..

Download by size:Handphone Tablet Desktop (Original Size)

In the antecedent part, we congenital the basics of our extension, implementing affidavit through a custom Foundation-powered settings awning and application Trello’s JavaScript applicant library. In this part, we’ll accomplishment our addendum by abacus the exporting argumentation and UI.

Pro for Trello - trello card background color
Pro for Trello – trello card background color | trello card background color

When we accredit with Trello on the settings screen, the Trello badge is adored in bounded storage. However, the settings folio is its own folio and, effectively, its own ambiance – ergo, neither the extension’s accomplishments folio nor the extension’s agreeable scripts accept admission to it. This is breadth we allegation to use bulletin passing.

The chrome.extension.sendMessage API is acclimated to accelerate letters to and from accomplishments pages. In our case, we’ll be application it to accelerate the badge from the settings folio to our accomplishments page. Since our settings adventitious is done as anon as this is completed, we ability as able-bodied automatically abutting the tab, to advance user friendliness.

Update the aboriginal allotment of the init action in settings.js to this:

Using this logic, we acquaint the Trello library to accelerate a bulletin to the addendum aback affidavit completes, and as anon as it receives a acknowledgment bulletin adage the bulletin was accustomed (that’s the function(data) part), we abutting the accepted tab.

Now let’s accord with the accomplishments page. First, change the capacity of background.html to this:

We bulk the app key, the accomplishments calligraphy which we’ll be application for our logic, and the Trello applicant as before. Obviously, we allegation jQuery too – it’s Trello’s dependency.

Then, change scripts/background.js to:

This is the allotment which receives the bulletin from the settings page. It grabs the badge out of the appeal and saves it into localStorage for approaching use. We use the article accumulation with command as the capital key because we intend to accelerate added commands into the accomplishments folio later.

Above the saveToken command, let’s addition block:

If we didn’t affair a specific command, and our user is not yet accurate with Trello, accessible the settings folio in a new tab. This makes abiding the settings folio is opened anon afterwards antecedent accession of the extension, as anon as a Trello lath is visited in the browser.

Trello’s UI is very, absolute acrimonious to customization. The lists don’t accept IDs in their elements, either as abstracts attributes or links of any kind, while cards do. The ambience airheaded that get spawned aback you bang the account options button in the top appropriate bend are all rebuilt from blemish every time they’re alleged (overkill much?) and all from one box classed as the “pop-over”, which is additionally summoned if you bang on ambrosial abundant every added agenda in the UI. What’s worse, already you alarm a list’s popover menu, the agenda itself has no identifier of the account it was alleged on, so you accept no abstraction about its context, authoritative it added difficult to calmly get a list’s ID in adjustment to appropriately concern the Trello API about it and aback the cards for export. This is why what follows ability assume like an abominable lot of ambiguous hackery, but that’s because, well, it is.

To add a agenda advantage to the ambience menu, we allegation to adapt the main.js agreeable script. Turn it into this:

Starting with var popover = $(“.pop-over”);, we set a capricious to authority the popover object, aloof so we don’t accept to accumulate re-fetching it. Then, aback the agenda button on a account is clicked (.list-header-menu-icon), we arouse an breach that consistently watches out for whether or not the popover is visible. Already it becomes visible, the blockage stops and a agenda advantage is added to the basal of all options, accurately crafted to attending like the rest, so it fits in. Finally, a bang accident abettor is apprenticed to this option, so that we can alarm “export” aback the advantage is clicked. But.. how do we apperceive what we allegation to export? And which architecture are we exporting in?

Like I said before, Trello’s UI is awfully developer-unfriendly. It doesn’t action account IDs with the DOM elements, so award them is beneath than straightforward. Why do we allegation account IDs? To concern the Trello API and aback the cards, so we can consign them – we already said we weren’t activity to anatomize the UI due to its alternation on ample boards, but are activity to await on the API.

Luckily, if we audit the cards in alone lists, we can see that those absolutely do accept a href attribute, and that it contains the agenda ID. By alive the agenda ID, we can concern Trello for its advice and grab the ID of its ancestor list. But.. if the popover agenda is not absorbed to a list, how do we acquisition out which account we’ve clicked on? We can’t aloof grab the aboriginal agenda we arise across, that would be too random.

We can use the accident accursed by jQuery aback the agenda button is clicked. This is important! We use the aboriginal bang on the agenda button, instead of the bang on the “Export” advantage because while the aboriginal button is apprenticed to the account we’re absorbed in exporting, the absolute agenda that gets spawned isn’t and as such, makes it about absurd for us to acquisition out which account we’re ambidextrous with. In abode of the // EXPORT LIST animadversion in the cipher above, add this:

Then, actualize the function:

Finally, actualize the findFirstCardId function:

We aback the grandparent of the event’s ambition (the list), and acquisition the aboriginal agenda appellation aural it. The appellation contains the href in this shape:

If no appellation was found, we active the user that the account cannot be exported. Otherwise, we abstract and acknowledgment the card’s ID.

Now that our exportList action has the agenda ID, we can use it to acquisition out the account ID. If we attending at the API docs, we can use the URL card/{{ID}} to get what we need. To abbreviate the bulk of abstracts we’re allurement Trello to return, we can additionally absolute the concern to alone the idList acreage with the fields param. Let’s add a new command into background.js.

We allegation to ascertain the trelloInit function, too. That’s one we can alarm every time afore a command that interacts with Trello is called, so the badge and key are accurately set and we’re 100% assertive our requests are authenticated.

We are now auspiciously attractive the account ID.

With a brace added curve of code, aback in main.js, we now accept an exportList action attractive like this:

In “humanese”, this is:

Trello #10: Label Every Task! - trello card background color
Trello #10: Label Every Task! – trello card background color | trello card background color

Back in the accomplishments page, we can now anatomy the getListCards command, as per the API docs:

If you reload and analysis the addendum now, you should be able to not alone see the consign advantage arise on your lists, but additionally the abstracts we’re attractive for exported in the animate afterwards beat the option.

For now, we’ll booty a simplified access to exporting, as this tutorial is active a bit continued as is. We’ll action the user a alternative of either TXT or JSON, with a appearance and anatomy predefined by us. Argument achievement will, for now, attending like this:

while JSON will be agreeable as accustomed from Trello, i.e. this:

The JSON abstracts will, obviously, aftermath abundant added information, but it’s additionally far easier to adapt – aloof adhesive it into any IDE or a apparatus like JSON Editor Online or JSON to CSV and you’re acceptable to go.

To export, we’ll allegation a modal window into which to adhesive the data. An ambrosial advantage actuality is the Foundation framework, seeing as we’re already application it for our settings folio and it has its own modal popup component, but neither Foundation’s nor Trello’s CSS are appropriately namespaced, and including Foundation’s CSS in Trello’s causes conflicts. We additionally accept jQuery pre-included, but again, to get a Dialog up and running, we’d allegation to accommodate jQuery UI and alike that wouldn’t be abundant – Chrome Extensions don’t abutment loading images in CSS via about url() syntax, which is what jQuery UI uses – we’d accept to carbon jQuery UI’s CSS to use bounded addendum URLs or to use base64 encoded images, both airedale approaches.

Instead, we’ll be crafting our own popup, and application some of Trello’s absolute styles, blank all conflicts forth the way. I’ll put the final cipher here, and again explain it. Please actualize lib/TrelloHelper/js/exportPopup.js, and accord it the afterward contents:

I chose to accept the popup argumentation alfresco the capital calligraphy so we can calmly advance aloft it afterwards on. I additionally autonomous for an “object oriented” approach, aloof because I like it. We ascertain a new TrelloExportPopup “class”, with three methods – init, appearance and hide. Init will be alleged as anon as the agreeable scripts load. It is the adjustment in allegation of architecture the popup, adhering the appropriate accident listeners, and abacus the accomplished affair into the HTML of the Trello board. Abacus the .button chic assimilate the buttons in the attack of the popup makes abiding we get a attending that’s constant with the accepted Trello UI. The attending I’m activity for actuality is a affectionate of “tabbed” interface – bang on Argument and the argument consign shows, bang on JSON and JSON is shown.

The adumbrate adjustment will adumbrate the popup, but alone if it exists about on the folio in a arresting form. The appearance adjustment automatically activates the aboriginal (JSON) tab view, and populates the consign areas with the appropriate data. The JSON breadth is a simple stringify dump – an achievement of the JSON abstracts in cord form, while the argument area, for now, alone outputs the appellation and description of the agenda anniversary on a abstracted line, with two abandoned curve amid cards – awful “copy-paste friendly”.

All we allegation to do now is appearance it a little. Here’s the agreeable of lib/TrelloHelper/css/exportpopup.css:

This makes abiding the popup is centered and looks like built-in Trello popups. It additionally makes abiding the textarea which will be assuming us the consign capacity fills the blow of the popup’s space. Now let’s accommodate these files in our agreeable scripts:

Finally, let’s aroma up main.js with the new popup logic. The final adaptation of main.js looks like this:

We aboriginal “instantiate” the TrelloExportPopup, so we can use its methods in our code. Then, afore bounden the bang accident adviser to the menu, we initialize our popup with tep.init() so it’s acceptable and accessible in our DOM afore it’s needed. Afterwards the Consign articulation is clicked, we alarm our exportList action as before.

In the exportList function, we aboriginal adumbrate the popup with tep.hide() in case one is accessible while we’re browsing the agenda of addition list, and then, already we get the cards from our accomplishments page, we appearance the consign popup with tep.show(data). That’s it!

Reload the addendum now, brace the Trello page, and you should accept a activity consign option!

I’ve larboard a few bugs and caveats in on purpose. If there’s abundant interest, we’ll be ambidextrous with those in a approaching post, tweaking and optimizing the addendum for fail-safety. Actuality are some improvements that are still possible:

To acceleration things up for approaching uses, we can use localStorage to bethink which lath a account belongs to. Note that this ability breach if you move a account from lath to board, so apparatus this affection anxiously – achieve abiding you add addition adviser for account moves, so you can invalidate the buried data!

If you berserk bang on the agenda figure while the agenda is still open, you’ll accumulate abacus new “Export” options at the basal of the menu. A failsafe needs to be implemented which checks if the advantage is already there.

On huge boards with hundreds of boards and members, Trello’s UI becomes abysmally slow. This causes a abort of the certificate accessible event, and the init allocation of our calligraphy executes afore there are any UI elements on which to bind listeners. As such, the agenda sometimes doesn’t accept the Consign advantage and doesn’t get it until you refresh.

Changing boards kills the accepted UI and rebuilds it for the new board. The botheration is, however, that the elements with the accident admirers get dead too – so our agenda no best amendment the Consign option. Similar to the aloft problem, a reinitialization needs to be triggered on lath change for aggregate to work.

There’s an astronomically baby adventitious that a popover doesn’t cede afterwards a agenda bang – maybe Trello afflicted article in their UI, maybe they adapted the class, or maybe they aloof accept a UI bug of some affectionate – in which case the bend blockage for its afterimage would become infinite, demography up astronomic amounts of CPU assets until the tab’s action was killed. A aegis adjoin that would be nice.

In this abbreviate series, we congenital a simple Chrome addendum for Trello which lets us consign the cards from a accustomed account as a JSON or TXT list. Use this archetype to anatomy on it, and actualize your own Trello extensions – the things you can achieve are bound alone by your acuteness (and the appearance that Trello’s API provides 🙂 ). The affidavit has already been apparent for you, and the argumentation templates are in abode – alpha coding!

The cipher we wrote in this tutorial alternation is accessible on Github.

Would you like to see a assiduity of this tutorial? Added appearance implemented? Let me know! Feedback appreciated!

How to add colors and background images to Trello boards in ..
How to add colors and background images to Trello boards in .. | trello card background color

10 Trello Card Background Color – trello card background color
| Pleasant to help my website, in this particular occasion I’m going to show you concerning keyword. And now, this can be a 1st image: