Commit 202a48c4 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Simplifica y reubica widget de visor PDF

Elimina vista detalle recursiva para visor PDF de documentos, que ya se
incluye dentro de la vista detalle de estos. Reorganiza la definición
para considerarlo un widget de la vista detalle de documentos (como se
ha hecho con las actividades).
parent 0bbb8a88
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ define([
	, 'src/detail/_GenerateReport'
	, 'templates/DocumentInfo'
	, 'app/designs/details/main/_DetailsBase'
	, 'src/detail/bibliography/DocumentPDF'
	, 'src/detail/bibliography/widget/DocumentPDF'
], function(
	redmicConfig
	, declare
+86 −0
Original line number Diff line number Diff line
define([
	'app/designs/base/_Main'
	, 'app/designs/details/Controller'
	, 'app/designs/details/Layout'
	, 'src/redmicConfig'
	, 'dojo/_base/declare'
	'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'src/component/base/_Module'
	, 'src/component/base/_Show'
	, 'src/component/base/_Store'
	, 'src/redmicConfig'
	, 'src/component/components/PDFViewer/PDFViewer'
], function(
	_Main
	, Controller
	, Layout
	, redmicConfig
	, declare
	declare
	, lang
	, _Module
	, _Show
	, _Store
	, redmicConfig
	, PDFViewer
) {

	return declare([Layout, Controller, _Main], {
	return declare([_Module, _Show, _Store], {
		//	summary:
		//		Vista detalle de documento PDF.
		//		Widget para mostrar un lector de documentos PDF incrustado.

		constructor: function(args) {

			this.target = redmicConfig.services.document;

			this.config = {
				noScroll: true,
				propsWidget: {
					omitTitleBar: true,
					resizable: false
				}
				ownChannel: 'documentPDF',
				target: redmicConfig.services.document
			};

			lang.mixin(this, this.config, args);
		},

		_setMainConfigurations: function() {
		_setOwnCallbacksForEvents: function() {

			this.widgetConfigs = this._merge([{
				pdf: {
					width: 6,
					height: 6,
					type: PDFViewer,
					props: {
						classWindowContent: 'view',
						title: 'PDF'
					}
				}
			}, this.widgetConfigs || {}]);
			this._onEvt('ME_OR_ANCESTOR_SHOWN', lang.hitch(this, this._onMeOrAncestorShown));
		},

		_refreshModules: function() {
		_initialize: function() {

			this._pdfViewer = new PDFViewer({
				parentChannel: this.getChannel()
			});
		},

			this._checkPathVariableId();
		getNodeToShow: function() {

			return this._pdfViewer.getNodeToShow();
		},

		_onMeOrAncestorShown: function() {

			this._refreshCurrentData();
		},

		_refreshCurrentData: function() {

			this._emitEvt('GET', {
				target: this.target,
@@ -71,27 +71,14 @@ define([
			}

			var pdfUrlProto = documentInternalUrl.replace('/api', redmicConfig.apiUrlVariable),
				pdfUrl = redmicConfig.getServiceUrl(pdfUrlProto),
				widgetInstance = this._getWidgetInstance('pdf');

			var callback = lang.hitch(this, this._loadPdfInWidget, pdfUrl);
				pdfUrl = redmicConfig.getServiceUrl(pdfUrlProto);

			if (!widgetInstance) {
				this._onceEvt('LAYOUT_COMPLETE', callback);
			} else {
				callback();
			}
			this._loadPdf(pdfUrl);
		},

		_loadPdfInWidget: function(pdfUrl) {

			var widgetInstance = this._getWidgetInstance('pdf');

			if (!widgetInstance) {
				return;
			}
		_loadPdf: function(pdfUrl) {

			this._publish(widgetInstance.getChannel('LOAD_PDF'), {
			this._publish(this._pdfViewer.getChannel('LOAD_PDF'), {
				url: pdfUrl
			});
		}