Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

adding screenshot before publishing app on the marketplace #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,22 @@ This example will generate the following HTML inside the app:
```

### Available Placeholders

#### Ticket sidebar

* {{ticket.id}} //not available for new tickets
* {{ticket.description}}
* {{ticket.requester.id}}
* {{ticket.requester.name}}
* {{ticket.requester.email}}
* {{ticket.requester.externalId}}
* {{ticket.requester.external_id}}
* {{ticket.requester.firstname}}
* {{ticket.requester.lastname}}
* {{ticket.requester.user_fields.YYY}} = custom user fields can be used
* {{ticket.assignee.user.id}}
* {{ticket.assignee.user.name}}
* {{ticket.assignee.user.email}}
* {{ticket.assignee.user.externalId}}
* {{ticket.assignee.user.external_id}}
* {{ticket.assignee.user.firstname}}
* {{ticket.assignee.user.lastname}}
* {{ticket.assignee.group.id}}
Expand All @@ -68,10 +71,30 @@ This example will generate the following HTML inside the app:
* {{current_user.id}}
* {{current_user.name}}
* {{current_user.email}}
* {{current_user.externalId}}
* {{current_user.external_id}}
* {{current_user.firstname}}
* {{current_user.lastname}}

#### User sidebar

* {{user.id}}
* {{user.name}}
* {{user.email}}
* {{user.phone}}
* {{user.external_id}}
* {{user.firstname}}
* {{user.lastname}}
* {{user.user_fields.YYY}} = custom user fields can be used
* {{user.organization.id}} (if user belongs to multiple organizations, only the default one will be used)
* {{user.organization.name}}
* {{user.organization.external_id}}
* {{user.organization.organization_fields.XXXXXXX}} = custom organization fields can be used


### Screenshots

![](/assets/screenshot.png)

### Making changes

If you wish to change the output, locate the app by looking for the name you choose in step 4 above. Use the widget to `Change Settings`
Expand Down
54 changes: 43 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,55 @@
requests: {
fetchUsers: function(ids) {
return {
url: helpers.fmt('/api/v2/users/show_many.json?ids=%@&include=organizations,groups', ids.join(',')),
url: helpers.fmt('/api/v2/users/show_many.json?ids=%@&include=organizations', ids.join(',')),
type: 'GET',
dataType: 'json'
};
}
},

events: {
'app.created' : 'onAppCreated',
'*.changed' : function(e) {
'app.created': 'onAppCreated',
'*.changed' : function(e) {
if (_.contains(this.fieldsToWatch(), e.propertyName))
return this.onAppActivated();
},
'fetchUsers.done' : 'onFetchUsersDone'
}
},

onAppCreated: function() {
switch (this.currentLocation()) {
case "user_sidebar":
this.prepareTemplateForUser();
break;
case "ticket_sidebar":
this.prepareTemplateForTicket();
break;
}
},

prepareTemplateForUser: function() {
this.ajax('fetchUsers', [this.user().id()]).done(function(data) {
var context = this.getUserContext(data);
this.prepareTemplate(context);
});
},

prepareTemplateForTicket: function() {
var userIds = _.compact(_.uniq([
(this.ticket().assignee().user() && this.ticket().assignee().user().id()),
this.currentUser().id(),
(this.ticket().requester() && this.ticket().requester().id())
]));

this.ajax('fetchUsers', userIds);
this.ajax('fetchUsers', userIds).done(function(data) {
var context = this.getTicketContext(data);
this.prepareTemplate(context);
});
},

onFetchUsersDone: function(data) {
prepareTemplate: function(context) {
var templateUris = this.getUriTemplatesFromSettings(),
templateOptions = { interpolate : /\{\{(.+?)\}\}/g },
context = this.getContext(data),
uris = _.map(templateUris, function(uri){
try {
uri.url = _.template(uri.url, templateOptions)(context);
Expand All @@ -50,7 +69,20 @@
return JSON.parse(this.settings.uri_templates);
},

getContext: function(data){
getUserContext: function(data) {
var context = _.clone(this.containerContext());
context.user = this.decorateUser(data.users[0]);

if (context.user.organization_id) {
context.user.organization = _.find(data.organizations, function(org) {
return org.id == context.user.organization_id;
});
}

return context;
},

getTicketContext: function(data) {
var context = _.clone(this.containerContext());

if (context.ticket.requester.id) {
Expand Down Expand Up @@ -82,7 +114,7 @@
}, this);
},

decorateUser: function(user){
decorateUser: function(user) {
var name = (user.name || '').split(' ');

user.firstname = name[0] || '';
Expand All @@ -91,7 +123,7 @@
return user;
},

fieldsToWatch: _.memoize(function(){
fieldsToWatch: _.memoize(function() {
return _.reduce(this.getUriTemplatesFromSettings(), function(memo, uri){
var fields = _.map(uri.url.match(/\{\{(.+?)\}\}/g), function(f){ return f.slice(2,-2); });

Expand Down
Binary file modified assets/logo-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "Url Builder App",
"name": "URL Builder App",
"author": {
"name": "Zendesk Services",
"email": "[email protected]"
},

"defaultLocale": "en",
"private": true,
"location": ["ticket_sidebar", "new_ticket_sidebar"],
"frameworkVersion": "0.5",
"location": ["ticket_sidebar", "new_ticket_sidebar", "user_sidebar"],
"frameworkVersion": "1.0",
"version": "1.1",

"parameters": [
{
Expand Down
6 changes: 3 additions & 3 deletions translations/en.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"app": {
"description": "Simple url generator",
"name": "Simple Url",
"description": "Simple URL generator",
"name": "Simple URL generator",

"parameters": {
"uri_templates": {
"label": "A JSON Array of urls.",
"label": "A JSON Array of URLs.",
"helpText": "See https://github.com/zendesklabs/url_builder_app/blob/master/README.md for more information."
}
}
Expand Down