Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Project snippets #16

Open
wants to merge 2 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
80 changes: 80 additions & 0 deletions samples/project/Get-Project-Information.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
id: ciz79iwgk0000456w9wch1l0m
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to id: ''

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change filename to get-project-information

gist: ''
source: PROJECT
author: Microsoft
name: Get information about the project
description: >-
Shows how to use project level fields to find things like the project's start
date
script:
content: |

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove 2 blank lines


$('#run').click(getProjectInformation);

// Get the specified fields for the active project.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove indentation

function getProjectInformation() {
var fields =
[Office.ProjectProjectFields.Start, Office.ProjectProjectFields.Finish, Office.ProjectProjectFields.GUID];
var fieldValues = ['Start: ', ' Finish: ', ' GUID: '];
var index = 0;
getField();

// Get each field, and then display the field values in the add-in.
function getField() {
if (index == fields.length) {
var output = '';
for (var i = 0; i < fieldValues.length; i++) {
output += fieldValues[i];
}
console.log(output);
}
else {
Office.context.document.getProjectFieldAsync(
fields[index],
function (result) {

// If the call is successful, get the field value and then get the next field.
if (result.status === Office.AsyncResultStatus.Succeeded) {
fieldValues[index] += result.value.fieldValue;
getField(index++);
}
else {
onError(result.error);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use console.log(result.error)

}
}
);
}
}
}

function onError(error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

console.log(error);
}
language: typescript
style:
content: /* Your style goes here */
language: css
template:
content: |-
<button id="run" class="ms-Button">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add short description: "This snippet demonstrates how to get project information such as..."

<span class="ms-Button-label">Run</span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run -> Get project information

</button>
language: html
libraries: |-
// Office.js
https://appsforoffice.microsoft.com/lib/1/hosted/Office.js

// NPM libraries
jquery
office-ui-fabric-js/dist/js/fabric.min.js
office-ui-fabric-js/dist/css/fabric.min.css
office-ui-fabric-js/dist/css/fabric.components.min.css
@microsoft/office-js-helpers/dist/office.helpers.min.js
core-js/client/core.min.js

// IntelliSense: Use dt~library_name for DefinitelyTyped or URLs to d.ts files
dt~office-js
dt~jquery
dt~core-js
@microsoft/office-js-helpers/dist/office.helpers.d.ts
48 changes: 48 additions & 0 deletions samples/project/Get-Task-GUID.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
id: ciz78veu00000456sgv494kcb
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change filename to get-task-guid

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id: ''

gist: ''
source: PROJECT
author: Microsoft
name: Get Task GUID
description: Get the selected task's GUID.
script:
content: |-
$('#run').click(run);

function run() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run -> getTaskGUID

Office.context.document.getSelectedTaskAsync(
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.log(asyncResult.error.message);
} else {
console.log('Selected task GUID is ' + asyncResult.value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

task -> task's

}
}
);
}
language: typescript
style:
content: /* Your style goes here */
language: css
template:
content: |-
<button id="run" class="ms-Button">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add short description

<span class="ms-Button-label">Run</span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run -> Get task GUID

</button>
language: html
libraries: |-
// Office.js
https://appsforoffice.microsoft.com/lib/1/hosted/Office.js

// NPM libraries
jquery
office-ui-fabric-js/dist/js/fabric.min.js
office-ui-fabric-js/dist/css/fabric.min.css
office-ui-fabric-js/dist/css/fabric.components.min.css
@microsoft/office-js-helpers/dist/office.helpers.min.js
core-js/client/core.min.js

// IntelliSense: Use dt~library_name for DefinitelyTyped or URLs to d.ts files
dt~office-js
dt~jquery
dt~core-js
@microsoft/office-js-helpers/dist/office.helpers.d.ts