commit 7fe16f0b770c93c02e4ca553a5a53db2581eac71
parent 7c1c13a0b8d8ff266f73e1326aef2e5335e2ac14
Author: Felicitus <felicitus@felicitus.org>
Date: Thu, 10 Oct 2013 15:41:43 +0200
Merge branch 'master' of github.com:partkeepr/PartKeepr
Diffstat:
13 files changed, 86 insertions(+), 79 deletions(-)
diff --git a/cronjobs/CreateRSSFeed.php b/cronjobs/CreateRSSFeed.php
@@ -1,62 +0,0 @@
-<?php
-namespace PartKeepr\Cronjobs;
-
-include(__DIR__."/../src/backend/PartKeepr/PartKeepr.php");
-
-use PartKeepr\PartKeepr,
- PartKeepr\Util\Configuration;
-
-PartKeepr::initialize();
-
-$dql = PartKeepr::getEM()->createQuery("SELECT p FROM PartKeepr\Part\Part p ORDER BY p.createDate DESC");
-$dql->setMaxResults(40);
-
-$parts = $dql->getResult();
-
-$rssDOM = new \DOMDocument("1.0", "UTF-8");
-$rssElement = $rssDOM->createElement("rss");
-$rssElement->setAttribute("version", "2.0");
-$rssDOM->appendChild($rssElement);
-
-$channel = $rssDOM->createElement("channel");
-
-$rssElement->appendChild($channel);
-$pTitle = $rssDOM->createElement('title', 'PartKeepr RSS Feed');
-$pLink = $rssDOM->createElement('link', 'http://www.partkeepr.org');
-$pDescription = $rssDOM->createElement('description', 'PartKeepr new part feed');
-$pLang = $rssDOM->createElement('language', 'en');
-
-// Here we simply append all the nodes we just created to the channel node
-$channel->appendChild($pTitle);
-$channel->appendChild($pDescription);
-$channel->appendChild($pLink);
-$channel->appendChild($pLang);
-
-foreach ($parts as $part) {
- $item = $rssDOM->createElement("item");
-
- $title = $rssDOM->createElement("title");
- $titleContent = $rssDOM->createTextNode($part->getName());
- $title->appendChild($titleContent);
-
- $description = $rssDOM->createElement("description");
- $descriptionContent = $rssDOM->createTextNode($part->getComment());
- $description->appendChild($descriptionContent);
-
- $category = $rssDOM->createElement("partkeepr:category");
- $categoryContent = $rssDOM->createTextNode($part->getCategory()->getCategoryPath());
- $category->appendChild($categoryContent);
-
- $pubDate = $rssDOM->createElement("pubDate", $part->getCreateDate()->format(DATE_RFC822));
-
- $item->appendChild($title);
- $item->appendChild($description);
- $item->appendChild($category);
- $item->appendChild($pubDate);
-
- $channel->appendChild($item);
-
-}
-
-$rssDOM->save(Configuration::getOption("partkeepr.files.path")."/feed.rss");
-
diff --git a/src/backend/PartKeepr/Distributor/Distributor.php b/src/backend/PartKeepr/Distributor/Distributor.php
@@ -58,6 +58,13 @@ class Distributor extends BaseEntity implements Serializable, Deserializable {
* @var string
*/
private $comment;
+
+ /**
+ * Holds the SKU lookup URL of the distributor
+ * @Column(type="string",nullable=true)
+ * @var string
+ */
+ private $skuurl;
/**
* Sets the name for the distributor
@@ -179,6 +186,23 @@ class Distributor extends BaseEntity implements Serializable, Deserializable {
public function getURL () {
return $this->url;
}
+
+ /**
+ * Sets the SKU lookup URL for this distributor
+ *
+ * @param string $skuurl The SKU lookup URL for this distributor
+ */
+ public function setSKUURL ($skuurl) {
+ $this->skuurl = $skuurl;
+ }
+
+ /**
+ * Returns the SKU lookup URL for this distributor
+ * @return string The SKU lookup URL
+ */
+ public function getSKUURL () {
+ return $this->skuurl;
+ }
/**
* Returns the distributor in serialized form.
@@ -193,7 +217,8 @@ class Distributor extends BaseEntity implements Serializable, Deserializable {
"email" => $this->getEmail(),
"comment" => $this->getComment(),
"phone" => $this->getPhone(),
- "fax" => $this->getFax()
+ "fax" => $this->getFax(),
+ "skuurl" => $this->getSKUURL()
);
}
@@ -225,7 +250,10 @@ class Distributor extends BaseEntity implements Serializable, Deserializable {
case "address":
$this->setAddress($value);
break;
+ case "skuurl":
+ $this->setSKUURL($value);
+ break;
}
}
}
-}-
\ No newline at end of file
+}
diff --git a/src/backend/PartKeepr/Distributor/DistributorManager.php b/src/backend/PartKeepr/Distributor/DistributorManager.php
@@ -20,7 +20,7 @@ class DistributorManager extends Singleton {
public function getDistributors ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") {
$qb = PartKeepr::getEM()->createQueryBuilder();
- $qb->select("st.id, st.name, st.url, st.email, st.comment, st.address")->from("PartKeepr\Distributor\Distributor","st");
+ $qb->select("st.id, st.name, st.url, st.email, st.comment, st.address, st.skuurl")->from("PartKeepr\Distributor\Distributor","st");
if ($filter != "") {
$qb = $qb->where("LOWER(st.name) LIKE :filter");
@@ -104,4 +104,4 @@ class DistributorManager extends Singleton {
return $query->getSingleResult();
}
-}-
\ No newline at end of file
+}
diff --git a/src/backend/PartKeepr/Part/PartAttachment.php b/src/backend/PartKeepr/Part/PartAttachment.php
@@ -99,7 +99,7 @@ class PartAttachment extends UploadedFile implements Serializable, Deserializabl
$this->replaceFromTemporaryFile($parameters["id"]);
} else {
// In case the part has been copied, the ID doesn't match. In that case we copy the attachment
- if ($this->getId() !== $parameters["id"]) {
+ if (intval($this->getId()) != intval($parameters["id"])) {
$otherAttachment = PartAttachment::loadById($parameters["id"]);
$this->replace($otherAttachment->getFilename());
$this->setOriginalFilename($otherAttachment->getOriginalFilename());
diff --git a/src/backend/PartKeepr/Part/PartManager.php b/src/backend/PartKeepr/Part/PartManager.php
@@ -140,7 +140,7 @@ class PartManager extends AbstractManager {
return array();
}
- $dql2 = "SELECT pr.name, part.id FROM PartKeepr\Project\Project pr JOIN pr.parts ppart JOIN ppart.part part WHERE ppart.part IN (:partids)";
+ $dql2 = "SELECT DISTINCT pr.id, pr.name, part.id FROM PartKeepr\Project\Project pr JOIN pr.parts ppart JOIN ppart.part part WHERE ppart.part IN (:partids)";
$projectQuery = PartKeepr::getEM()->createQuery($dql2);
$projectQuery->setParameter("partids", $partIds);
@@ -152,7 +152,7 @@ class PartManager extends AbstractManager {
}
$projects[$projectResult["id"]][] = $projectResult["name"];
}
-
+
return $projects;
}
diff --git a/src/frontend/css/PartKeepr.css b/src/frontend/css/PartKeepr.css
@@ -215,4 +215,12 @@ td.o2 {
text-align: center;
width:18px;
line-height:18px
+}
+
+.x-form-trigger-help {
+ background-image: url('../resources/images/trigger-help.gif'),-webkit-linear-gradient(top, #dee3e6 0%, #fcfcfd 12%, #fff 100%);
+}
+
+.x-form-trigger-link {
+ background-image: url('../resources/images/trigger-link.png'),-webkit-linear-gradient(top, #dee3e6 0%, #fcfcfd 12%, #fff 100%);
}
\ No newline at end of file
diff --git a/src/frontend/js/Components/Distributor/DistributorEditor.js b/src/frontend/js/Components/Distributor/DistributorEditor.js
@@ -14,6 +14,14 @@ Ext.define('PartKeepr.DistributorEditor', {
name: 'url',
fieldLabel: i18n("Website")
},{
+ xtype: 'triggerfield',
+ name: 'skuurl',
+ fieldLabel: i18n("SKU URL"),
+ triggerCls: 'x-form-trigger-help',
+ onTriggerClick: function() {
+ Ext.Msg.alert(i18n("Help"), i18n("Enter the URL of the distributor's SKU URL. Use %s as a placeholder for the SKU. Example: http://de.farnell.com/product/dp/%s"));
+ }
+ },{
xtype: 'textfield',
name: 'email',
fieldLabel: i18n("Email")
diff --git a/src/frontend/js/Components/Part/Editor/PartDistributorGrid.js b/src/frontend/js/Components/Part/Editor/PartDistributorGrid.js
@@ -102,13 +102,34 @@ Ext.define('PartKeepr.PartDistributorGrid', {
xtype : 'CurrencyField',
allowBlank : true
}
- },{
+ }, {
header : i18n("SKU"),
dataIndex : 'sku',
flex : 1,
editor : {
- xtype : 'textfield',
- allowBlank : true
+ xtype : 'trigger',
+ allowBlank : true,
+ triggerCls : 'x-form-trigger-link',
+
+ onTriggerClick: function() {
+
+ var sku = this.value;
+ var distributorId = this.ownerCt.floatParent.
+ getSelectionModel().
+ getSelection()[0].
+ get("distributor_id");
+
+ var distributorRecord = PartKeepr.getApplication().
+ getDistributorStore().
+ findRecord("id", distributorId);
+
+ var skuurl = distributorRecord.get("skuurl");
+
+ if (skuurl) {
+ skuurl = skuurl.replace("%s", this.value);
+ window.open(skuurl, '_blank');
+ }
+ }
}
} ];
diff --git a/src/frontend/js/Components/Picker/CharPicker.js b/src/frontend/js/Components/Picker/CharPicker.js
@@ -30,7 +30,7 @@ Ext.define('PartKeepr.picker.Char', {
* @cfg {Boolean} allowReselect
* If set to true then reselecting a char that is already selected fires the {@link #select} event
*/
- allowReselect : false,
+ allowReselect : true,
/**
* @property {String[]} chars
diff --git a/src/frontend/js/Components/Project/ProjectReport.js b/src/frontend/js/Components/Project/ProjectReport.js
@@ -58,12 +58,18 @@ Ext.define('PartKeepr.ProjectReportView', {
header: i18n("Quantity"), dataIndex: 'quantity',
width: 50
},{
- header: i18n("Part"),
+ header: i18n("Part Name"),
renderer: function (val, p, rec) {
return rec.part().getAt(0).get("name");
},
flex: 1
},{
+ header: i18n("Part Description"),
+ renderer: function (val, p, rec) {
+ return rec.part().getAt(0).get("description");
+ },
+ flex: 1
+ },{
header: i18n("Remarks"),
dataIndex: 'remarks',
flex: 1
diff --git a/src/frontend/js/Models/Distributor.js b/src/frontend/js/Models/Distributor.js
@@ -8,10 +8,11 @@ Ext.define("PartKeepr.Distributor", {
{ name: 'address', type: 'string'},
{ name: 'phone', type: 'string'},
{ name: 'fax', type: 'string'},
- { name: 'email', type: 'string'}
+ { name: 'email', type: 'string'},
+ { name: 'skuurl', type: 'string'}
],
proxy: PartKeepr.getRESTProxy("Distributor"),
getRecordName: function () {
return this.get("name");
}
-});-
\ No newline at end of file
+});
diff --git a/src/frontend/resources/images/trigger-help.gif b/src/frontend/resources/images/trigger-help.gif
Binary files differ.
diff --git a/src/frontend/resources/images/trigger-link.png b/src/frontend/resources/images/trigger-link.png
Binary files differ.