Skip to content

Commit

Permalink
Merge pull request #3 from somenathmaji/staging
Browse files Browse the repository at this point in the history
repro ItemChanged issue
  • Loading branch information
somenathmaji authored Sep 22, 2021
2 parents b2c7f1f + 91dddef commit 80eccd5
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Pinnate"/>
<Description DefaultValue="A template to get started."/>
<IconUrl DefaultValue="https://localhost:3000/assets/icon-64.png"/>
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-128.png"/>
<IconUrl DefaultValue="https://localhost:4000/assets/icon-64.png"/>
<HighResolutionIconUrl DefaultValue="https://localhost:4000/assets/icon-128.png"/>
<SupportUrl DefaultValue="https://www.pinnate.com/help"/>
<AppDomains>
<AppDomain>https://www.pinnate.com</AppDomain>
Expand All @@ -23,7 +23,7 @@
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:3000/index.html"/>
<SourceLocation DefaultValue="https://localhost:4000/index.html"/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
Expand Down Expand Up @@ -70,12 +70,12 @@
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:4000/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:4000/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:4000/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/index.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:4000/index.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Pinnate Add-in"/>
Expand Down Expand Up @@ -124,12 +124,12 @@
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:4000/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:4000/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:4000/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:4000/taskpane.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Pinnate Add-in"/>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --port 3000 --ssl true --ssl-key ./localhost.key --ssl-cert ./localhost.crt",
"start": "ng serve --port 4000 --ssl true --ssl-key ./localhost.key --ssl-cert ./localhost.crt",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions src/app/another/another.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
another works!
</p>
15 changes: 15 additions & 0 deletions src/app/another/another.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-another',
templateUrl: './another.component.html',
styleUrls: ['./another.component.css']
})
export class AnotherComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
16 changes: 16 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { AnotherComponent } from "./another/another.component";

const routes: Routes = [
{
path: "another",
component: AnotherComponent
}
];

@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true, enableTracing: true })],
exports: [RouterModule]
})
export class AppRoutingModule { }
6 changes: 5 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{{subject}}
<p>
app works!
</p>
<router-outlet></router-outlet>

32 changes: 0 additions & 32 deletions src/app/app.component.spec.ts

This file was deleted.

28 changes: 13 additions & 15 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
import { ChangeDetectorRef, Component, NgZone, OnInit } from "@angular/core";
import { OfficeService } from "./office.service";
import { Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{

public subject = "";

constructor(
private officeService : OfficeService
private router: Router
) {}

ngOnInit(): void {
this.subject = (window as any).Office.context.mailbox.item.subject;
if (this.officeService.isItemChangedEventAvailable()) {
console.log("[app-component] Registering to ItemChanged event");
this.officeService.registerEventHandler((window as any).Office.EventType.ItemChanged, func => this.updateSubject());
} else {
console.warn("[app-component] Skipping registering for ItemChanged event");
}
(<any>window).Office.context.mailbox.addHandlerAsync(
(<any>window).Office.EventType.ItemChanged,
() => {console.error('hello!!'); this.itemChangedEventHandler()},
() => {console.error('registered')});
}

public updateSubject() {
this.subject = (window as any).Office.context.mailbox.item.subject;
console.log(this.subject);
public itemChangedEventHandler = () => {
this.switchView();
}

public switchView = () => {
this.router.navigate(["another"], { replaceUrl: true });
}
}
10 changes: 6 additions & 4 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { OfficeService } from './office.service';
import { AnotherComponent } from './another/another.component';
import { AppRoutingModule } from './app-routing.module';

@NgModule({
declarations: [
AppComponent
AppComponent,
AnotherComponent
],
imports: [
BrowserModule
BrowserModule,
AppRoutingModule
],
providers: [
OfficeService
],
bootstrap: [AppComponent]
})
Expand Down
15 changes: 0 additions & 15 deletions src/app/office.service.spec.ts

This file was deleted.

51 changes: 0 additions & 51 deletions src/app/office.service.ts

This file was deleted.

0 comments on commit 80eccd5

Please sign in to comment.